Utilizing the responsive nature of the Bootstrap container, which employs media queries to set a maximum width.
The primary purpose of the container is to specify width, auto margins, and padding. Other grid classes (such as row, col) do not rely on it, making it simpler to create a custom container.
To create your own container-940
...
.container-940 {
width: 100%;
max-width: 940px;
padding-right: 15px;
padding-left: 15px;
margin-right: auto;
margin-left: auto;
}
Demo: https://www.example.com/code-demo
Alternatively, if you prefer to use the existing .container
, you can make modifications by...
@media (min-width: 992px) {
.container {
max-width: 940px;
}
}
@media (min-width: 1200px) {
.container {
max-width: 940px;
}
}
Demo: https://www.example.com/code-demo
If you wish to adjust the max-width to be smaller for smaller screens, you can customize the media queries accordingly:
@media (min-width: 576px) {
.container {
max-width: ??px;
}
}
@media (min-width: 768px) {
.container {
max-width: ??px;
}
}
@media (min-width: 992px) {
.container {
max-width: 940px;
}
}
@media (min-width: 1200px) {
.container {
max-width: 940px;
}
}