Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Change width property only of nav property in CSS3 and Bootstrap

Change width property only of nav property in CSS3 and Bootstrap

Problem

I have my HTML file that looks like the follows:


  
//main contents here

So, my HTML has one .container and within it I put .nav as well as main contents.

And I set the following property on CSS3 {width: 99%;} on .container.

However, when I open it up on the browser, not only do the main contents but also nav is narrowed by 1% due to the above setting. What I want to know is, how can I make the container narrowed by 1% but except the nav?

I use Stylus, and I tried to write the following code:

.container
  header
    width: 100%

, but this is not working and the result remains 99% on the window.
I also tried to write &header to refer to the parent .container, but the result was still the same... Why?

Problem courtesy of: Blaszard

Solution

You should do it the other way around, something like..

This way, your

won't be affected by your width change, and all the inner content will be.

If you absolutely need to have it the way you structured it... do something like:

.container-width { width: 99%; }

This way, you are not modifying bootstrap grid structure across the board (which can cause you many headaches down the road), and instead you are applying your custom width to your one element (and since it is a class, you can add this same class to any other Container to modify that as well.)

Solution courtesy of: feitla

Discussion

View additional discussion.



This post first appeared on CSS3 Recipes - The Solution To All Your Style Problems, please read the originial post: here

Share the post

Change width property only of nav property in CSS3 and Bootstrap

×

Subscribe to Css3 Recipes - The Solution To All Your Style Problems

Get updates delivered right to your inbox!

Thank you for your subscription

×