Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set the width of fluid Bootstrap containers?

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.

like image 792
cameraobscura Avatar asked Sep 23 '13 16:09

cameraobscura


People also ask

How do I resize a container in Bootstrap?

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.

How wide is Bootstrap container?

. container-fluid , which is width: 100% at all breakpoints. .

Which Bootstrap class will you use to provide a responsive full width container?

container-fluid class provides a full width container, spanning the entire width of the viewport.


1 Answers

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.

like image 54
Patrick Evans Avatar answered Oct 17 '22 08:10

Patrick Evans