Last active
March 30, 2017 21:34
-
-
Save chikien276/9c88b45c04c4e5375818fc2f9d1ce33f to your computer and use it in GitHub Desktop.
Bootstrap: 100% sceen width child element inside .container with no multiple .container elements, no javascript.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.hr-div { | |
padding: 10px; | |
} | |
.hr-div div { | |
border-top: 1px solid #f68e92; | |
position: absolute; | |
width: 100vw; | |
left: 0; | |
} | |
@media (min-width: 576px) { | |
.hr-div div { | |
left: calc(510px/2 - 50vw); | |
} | |
} | |
@media (min-width: 768px) { | |
.hr-div div { | |
left: calc(690px/2 - 50vw); | |
} | |
} | |
@media (min-width: 992px) { | |
.hr-div div { | |
left: calc(930px/2 - 50vw); | |
} | |
} | |
@media (min-width: 1200px) { | |
.hr-div div { | |
left: calc(1110px/2 - 50vw); | |
} | |
} |
markup
<div class="hr-div">
<div></div>
</div>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The reason are inside _grid.scss we have
`
@media (min-width: 576px) {
.container {
width: 540px;
max-width: 100%;
}
}
@media (min-width: 768px) {
.container {
width: 720px;
max-width: 100%;
}
}
@media (min-width: 992px) {
.container {
width: 960px;
max-width: 100%;
}
}
@media (min-width: 1200px) {
.container {
width: 1140px;
max-width: 100%;
}
}`
and the .container have padding left and right 15px each. So for 1200px we have child width 1110px and so on.