XF 2.1 Adjusting the size of the Nav Bar

Catsmother

Active member
I am making a style and I can't find where to adjust the width of the Navigation bars.
Is there a way of doing this please?
 
The width of the navigation inherits from: Style properties -> Page setup -> Maximum page width. If you increase the value here it'll increase the overall page width of the entire site.

If you want to just increase the navigation, you can add something like this to your extra.less template:

Code:
.p-nav .p-nav-inner, .p-sectionLinks .p-sectionLinks-inner {
    max-width: 1500px;
}
 
The width of the navigation inherits from: Style properties -> Page setup -> Maximum page width. If you increase the value here it'll increase the overall page width of the entire site.

If you want to just increase the navigation, you can add something like this to your extra.less template:

Code:
.p-nav .p-nav-inner, .p-sectionLinks .p-sectionLinks-inner {
    max-width: 1500px;
}
Thank you :)

I tried that code but I want to reduce the nav bar, is there a code for that please?
 
Any CSS you receive on these forums should go inside the template extra.less normally. Go to appearance -> templates -> extra.less and place the code there.
 
Any CSS you receive on these forums should go inside the template extra.less normally. Go to appearance -> templates -> extra.less and place the code there.
Thanks, I did what you said and all it did was move the text. I want the nav tree the same size as the forums.
 
Try this in style properties > Header and Navigation > Navigation row > freeform CSS

Code:
max-width:1000px;
margin:auto;

Use what width you want

Or
in extra.less

Code:
.p-nav
{max-width:1000px;
margin:auto}
 
Try this in style properties > Header and Navigation > Navigation row > freeform CSS

Code:
max-width:1000px;
margin:auto;

Use what width you want

Or
in extra.less

Code:
.p-nav
{max-width:1000px;
margin:auto}
Thanks that has worked. Just one more question though it did not do anything to the second row on the navigation. the row where new posts are etc.
 
extra css

Code:
.p-sectionLinks

{max-width:1000px;
margin-auto}

Or same with Style properties but sub navigation row freeform CSS

Code:
max-width:1000px;
margin-auto;
 
Is this what you are trying to achieve?

Image1.webp

If so, it's done by setting .p-sectionLinks-inner to 964px. and .p-nav to 960px. I also moved the background color from .p-sectionLinks to .p-sectionLinks-list.
 
Yeah this is what I am trying to do :) Thank you!

Do I need to go in the templates to do that? and if so what area?

Appearance -> Styles -> The name of the style you are editing -> Templates -> extra.less

HTML:
.p-sectionLinks-inner
{
    max-width: 964px;
    margin: 0 auto;
}

.p-nav
{
    max-width: 960px;
    margin: 0 auto;
}

.p-sectionLinks
{
    background: none;
}

.p-sectionLinks-list
{
    background: #f5f5f5;
}

The above works, and !important is not required. The #f5f5f5 color I used is just an example, replace with your own, :)

To move the box-shadow that covers the width of your forum as you scroll down and the navigation becomes stuck to the new narrower nav bar, you will need to edit the PAGE_CONTAINER template for your style:

At approx. line 136 find <nav class="p-nav"> and replace with <nav class="p-navSticky p-navSticky--primary p-nav" data-xf-init="sticky-header">

Next at approx. line 382 find <div class="p-navSticky p-navSticky--primary" data-xf-init="sticky-header"> and replace with: <div class="p-navSticky">
 
Last edited:
Appearance -> Styles -> The name of the style you are editing -> Templates -> extra.less

HTML:
.p-sectionLinks-inner
{
    max-width: 964px;
    margin: 0 auto;
}

.p-nav
{
    max-width: 960px;
    margin: 0 auto;
}

.p-sectionLinks
{
    background: none;
}

.p-sectionLinks-list
{
    background: #f5f5f5;
}

The above works, and !important is not required. The #f5f5f5 color I used is just an example, replace with your own, :)

To move the box-shadow that covers the width of your forum as you scroll down and the navigation becomes stuck to the new narrower nav bar, you will need to edit the PAGE_CONTAINER template for your style:

At approx. line 136 find <nav class="p-nav"> and replace with <nav class="p-navSticky p-navSticky--primary p-nav" data-xf-init="sticky-header">

Next at approx. line 382 find <div class="p-navSticky p-navSticky--primary" data-xf-init="sticky-header"> and replace with: <div class="p-navSticky">
Thank you so much for this, it worked :)

Just the Page container, I have this line on 136

<span class="p-nav-menuText">{{ phrase('menu') }}</span>
 
Top Bottom