Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8686609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:53:45+00:00 2026-06-12T22:53:45+00:00

OK, first off, I am NOT really familiar with javascript, so please forgive if

  • 0

OK, first off, I am NOT really familiar with javascript, so please forgive if this seems a really dumb question…

Here’s my code to dynamically resize header items depending on window height (logo, title) and navigation bar depending on width of dynamically sized logo & title:

function titlesize (){
  var winsize = {
    width: document.documentElement.clientWidth || window.innerWidth || document.body.offsetWidth,
    height: document.documentElement.clientHeight || window.innerHeight || document.body.offsetHeight
  };

  var titlefont = $(".title");
  var logo= $(".logo");
  var logow = winsize.height * 0.2;
  var logoh = winsize.height * 0.15;
  var titlefontsize = winsize.height * 0.03;
  var titlew = titlefontsize * 7;

  if (winsize.height > 580) {
    logo.css({width: logow, height: logoh});
    titlefont.css('font-size', function(){return (titlefontsize);});
    titlefont.css('width', function(){return (titlew);});
  }
  else {
    var logow = "150";
    var logoh = "100";
    var titlew = "122.5";
    logo.css({width: logow, height: logoh});
    titlefont.css({'font-size': "17.5px", width: titlew});
  }

  if ((winsize.width > 480) && ((winsize.width * 0.9) < (logow + titlew + 420))) {
    $("nav").css({float: "left"});
  }
}
$(document).ready(function() {titlesize(); $(window).resize(titlesize);$(window).load(titlesize);});

Explained: I have a title logo and text dynamically resized according to window height rather than the usual width, so that the overall header does not take too much of the screen (especially on mobile devices in landscape).

Navigation bar will then be placed: top right if there is enough space (default), or below header (float:left).

The problem is: Window resizing does resize logo and text just fine, but not the nav bar. That does only react on reload, not on resize. Is there any reason why?

I suspect it is because of the dependency of those dynamic variables deriving from the first if else statement. I’m pretty sure there is a simple solution, but what?

Thanks for any help.

PS: tried to make a jsfiddle, but it gives me POST error (no idea why, there is no form submit or anything like that)

EDIT & SOLUTION

Figured out why it did not work: simply made a mistake in the var declarations

I set in the else part of the function vars logow and titlew to fixed values in quotes, thus js took them as text rather than numbers. Hence, the calculation for the nav just messed up. Declaring those vars as numbers (var logow = 150;) did the trick.

Thanks nevertheless for your help and the great hint at media query with heights!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T22:53:46+00:00Added an answer on June 12, 2026 at 10:53 pm

    DominicaJune is right. You can use media queries for height:

    http://trentwalton.com/2012/01/11/vertical-media-queries-wide-sites/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First off, I am not a Unix expert by any stretch, so please forgive
So first off, this is a homework assignment, so please don't write any code
First off I'm not sure that's the proper title for this question but hopefully
First off my apologies for how disgusting this code is, it is not my
First off, let me preface this question by stating that I'm really a pretty
First off, this is NOT a duplicate of: Turn a C string with NULL
First off, apologies if this is a complete noob question which could easily be
Here's the question first: Is this possible? I'm taking my inspiration from Joe Wrobel's
First off, I apologize if this question has been asked before. I've done a
First off, I apologize if I'm not using the right terms in my question

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.