, , , , , , .
, , .
<main>
[your content here]
</main>
main {
background: red;
position: relative;
width: 1000px;
margin: 0 auto;
}
main::before {
background: blue;
content: ' ';
display: block;
position: absolute;
top: 0;
bottom: 0;
left: -50vw;
right: -50vw;
z-index: -1;
}
:: after, .
, , , ( ) . , <main>. , , . , .
, . ( - <main>/your element) , , . overflow-x: hidden , . , , .
, , ( , , ), , .
I donโt know how this solution works in terms of performance, since I donโt know how rendering engines work these days. There was a time when everything that was off the screen was also shown (hence the reason why the infamous technique of hiding elements quickly turned into a trash can), but this should not be a problem these days.
source
share