EDITED: Maybe I should ask which selector sets up the side padding when the screen is reduced to below 480px width? I have been browsing bootstrap-responsiveness.css for a while to locate this but nothing seems to affect this.
Original I basically want to remove any default padding or margin set for responsiveness on smaller device screens.
I have a background color
overridden on container-fluid
selector and for larger screen they render perfectly 100% across the width but they the screen is reduced to smaller sizes,
by default, Bootstrap seems to add a margin or padding oncontainer-fluid
or container
.
<div class="container-fluid">
<div class="row-fluid">
test
</div>
</div>
If I use custom css to overwriting Bootstrap's default style, what media query or selector should I overwrite to for removing this padding on smaller screens?
To solve problems like this I'm using CSS - fastest & simplest way I think... Just modify it by your needs...
The CSS by Paulius Marčiukaitis worked nicely for my Genesis theme, here's what how I further modified it for my requirement:
}
I have had this problem occur on sites that used similar formatting and code and I have racked my brain over what was the missing detail that made some of my sites work, and some not.
For Bootstrap 3: The answer for me was not in rewriting css for .container-fluid, .row or resetting margins, the consistent pattern that I realized was the length of longer words were throwing off the design and creating margins.
The solution steps:
Test your page by temporarily deleting sections that contain containers and test your site on small browsers. This will identify your problem container.
You may have a div formatting problem. If you do, fix it. If all is well then:
Identify if you have used long words that are not wrapping. If you cannot change the word (like for tag lines or slogans, etc.)
Solution 1: Format the font to smaller size in your media query for smaller screen (I usually find @media (max-width: 767px) to be sufficient).
OR:
Solution 2:
The @media query specifically for 'phones' is..
But, you may want to remove the padding/margin for any smaller screen sizes. By default, Bootstrap adjusts margins/padding to the body, container and navbars at 978px.
Here are some queries that have worked (in most cases) for me:
Demo
Update for Bootstrap 4
Use the new responsive spacing utils which let you set padding/margins for different screen widths (breakpoints): https://stackoverflow.com/a/43208888/171456
This thread was helpful in finding the solution in my particular case (bootstrap 3)