Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 1
pflombard

How to keep nav bar height constant across various window sizes

Question

Posted (edited)

Site URL: http://s15.squarespace.com/guitar-kids-a-lesson-1

Hi Community! Can you help?

I'd like to control the height of my nav bar (header) more precisely between Desktop, Tablets and Mobile.

If I look at www.apple.com and youtube.com, then I notice that the height of their nav bar remains constant when I drag the browser window from desktop size to mobile size.

But with my SquareSpace 7.1 site, the nav bar height does not remain constant while I drag the browser window smaller or larger.

How would one achieve a consistent height for the nav bar, as with Youtube and Apple, across devices / window sizes ?

My own attempt at CSS (see below) works to some degree, but only at specific, static window sizes, but not when I manually drag the browser window left and right. The height of the nav bar keeps shifting as the window size increases or decreases. The same applies to the logo, text and burger bar inside the nav bar, which also shifts when the window size shifts (see screenshots).

Any advice would be greatly appreciated!

Thank you kindly.

/* ----------MY ATTEMPT AT CSS TO KEEP THE NAV BAR HEIGHT CONSISTENT ACROSS ALL WINDOW SIZES AND DEVICES------------------- */

// CSS FOR TABLET AND MOBILE //
@desktop: ~"only screen and (min-width: 1025px)";
@mobile:  ~"only screen and (max-width: 767px)";
@tablet:  ~"only screen and (min-width: 768px) and (max-width: 1024px)";

/* ----------------------------- */
// HEADER HEIGHT - LESSON 1 - DESKTOP //
@media @desktop {
#collection-5ece5287d9f131439a163282 {
#header .header-inner {
 padding-top: 0px;
 padding-bottom: 15px;
}
  .header-announcement-bar-wrapper {
  margin-top: -15px;
  height: 90px !important;
}
}
}

// HEADER HEIGHT - LESSON 1 - MOBILE //
@media @mobile {
#collection-5ece5287d9f131439a163282 {
#header .header-inner {
 margin-top: -15px;
}
.header-announcement-bar-wrapper {
  margin-top: -9px;
  height:80px !important;
}
}
}

// HEADER HEIGHT - LESSON 1 - TABLET //
@media @tablet {
  #collection-5ece5287d9f131439a163282 {
#header .header-inner {
 margin-top: -5px !important;
}
.header-announcement-bar-wrapper {
  margin-top: 0px;
  height:80px !important;
}
}
}

 

Screen Shot 2020-07-21 at 2.59.20 PM.png

Screen Shot 2020-07-21 at 2.59.42 PM.png

Screen Shot 2020-07-21 at 3.00.03 PM.png

Screen Shot 2020-07-21 at 3.01.19 PM.png

Edited by pflombard

Share this post


Link to post

2 answers to this question

Recommended Posts

  • 0
.header-announcement-bar-wrapper {
    height: 100% !important;
}

 


Free Squarespace 7.1 Anchor Link and Accordion Plugins available here!

If I replied to one of your questions with code, it was either CSS or jQuery.

To add CSS, go to Design -> Custom CSS

jQuery needs some additional steps. Head here: https://code.jquery.com/ and click on minified, under jQuery 3.x and copy that code into Squarespace.

After you put that code into the code injection section in Squarespace, you can add the code I supplied. The code from me will need <script> added before it and </script> added after it (only for jQuery).

There are two places that you can add the code, one is site wide (adds to all pages). Settings -> Advanced -> Code Injection

The other is for a specific page (adds to one page only). Pages -> Gear Icon next to the page -> Advanced

Share this post


Link to post
  • 0
Posted (edited)

Thanks so much for getting back to me, @rwp

I tried this, but it doesn't seem to have any effect to help keep the nav bar height constant while I change the browser window size.

But @tuanphan recommended that I add padding at the top and bottom and this appears to have done the trick!:

Now the height remains constant when I drag the browser window left or right.

.header-announcement-bar-wrapper {
    padding-top: 10px !important;
    padding-bottom: 10px !important;
    height: 100% !important;
}

 

Edited by pflombard

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment


×
×
  • Create New...