I just want to clear out one thing. If I am using "container-fluid"
class, it means I can not have something like this in bootstrap.css:
.container-fluid{
width: 1170px;
}
I tried to set in pixels and the responsive nature simply switched off. While setting in % it works. In other words, my question is like this: How can I set the fixed width of container-fluid? Or was it simply not meant by default by bootstrap developers?
I already read this link: Fluid or fixed grid system, in responsive design, based on Twitter Bootstrap
But simply can not find anything there regarding the responsive nature and fixed width with container-fluid.
You can either use <div class="container-fixed"> or your own media query in which you can specify the custom width for various resolution. Show activity on this post. The default Bootstrap . container class has 15px padding on both left and right sides.
. container-fluid , which is width: 100% at all breakpoints. .
container-fluid class provides a full width container, spanning the entire width of the viewport.
setting a px
width is making it static, you would have to employ a different technique to make it responsive after that like javascript
that is why a % is used.
If you are wanting to make the container not go wider than 1170px
use
.container-fluid {
max-width:1170px;
}
max-width will make it so if the users screen is wider than 1170px
the container will go only up to 1170px
wide. This will make it so the responsive mechanisms will still work.
Of course using .container-fluid
as the selector will change how all container-fluid
elements act so think about adding a second class to that element and setting the style to it.
html
<div class="container-fluid maxWidth"></div>
css
.maxWidth {
max-width:1170px;
}
If you are wanting the container to be fixed no matter what, that will make the contents inside non-responsive as they would not be able to tell when the screen has changed size as the container would not change size.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With