Reputation: 11721
Is it possible to set the max-width
of a bootstrap container using the default settings? (without modifying the code)
I am trying to set the max-width of the container to 540px, but the css rule gets overwritten to 1140px;
Code:
<div class="container-sm">
<div class="border border-primary">
<p>This content should have max-width of 540px</p>
</div>
</div>
Result:
https://codepen.io/catalingavan/pen/NWGapKa
Upvotes: 1
Views: 3046
Reputation: 961
The bootstrap containers (container-sm, container-md, container-lg, container-xs) change their width based on the type of device and class used.
so in your case - since you're using container-sm, I simply created an override
.container-sm {
max-width: 540px;
}
Modified your codepen - https://codepen.io/AbhijatSaxena/pen/GRpMWZr
(I would also recommend setting the max-width for other types of containers as well for consistency)
Upvotes: 2