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?
If the screen width is 700px , then the padding value will be padding-right:15px . If the screen width is something between 1000px and 700px then the padding value must change proportionally.
If you want to remove the padding for all the screens then you can go to your theme module and set padding as 0px for the top, left, and right. If you want to do the same for a specific screen you add a new CSS class from Style editor of the screen.
l - sets margin-left or padding-left. r - sets margin-right or padding-right. x - sets both padding-left and padding-right or margin-left and margin-right. y - sets both padding-top and padding-bottom or margin-top and margin-bottom.
The @media query specifically for 'phones' is..
@media (max-width: 480px) { ... }
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:
@media (max-width: 978px) { .container { padding:0; margin:0; } body { padding:0; } .navbar-fixed-top, .navbar-fixed-bottom, .navbar-static-top { margin-left: 0; margin-right: 0; margin-bottom:0; } }
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
The problem here is much more complex than removing the container padding since the grid structure relies on this padding when applying negative margins for the enclosed rows.
Removing the container padding in this case will cause an x-axis overflow caused by all the rows inside of this container class, this is one of the most stupid things about the Bootstrap Grid.
Logically it should be approached by
.container
class for anything other than rows.container
class that has no padding for use with non-grid html.container
padding on mobile you can manually remove it with media queries then overflow-x: hidden;
which is not very reliable but works in most cases.If you are using LESS
the end result will look like this
@media (max-width: @screen-md-max) { .container{ padding: 0; overflow-x: hidden; } }
Change the media query to whatever size you want to target.
Final thoughts, I would highly recommend using the Foundation Framework
Grid as its way more advanced
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