In general, no way. Was wrong, in some cases possible.
You can easily climb out only for a fixed distance, but stretch to the edges of the browser window will not work.
section { width: 200px; outline: 1px dotted red; height: 100px; position: relative; margin: auto; } section:after { content: ""; position: absolute; left: -50px; right: -50px; bottom: 0; height: 50px; background: silver; }
<section></section>
To stretch to the brim, you can use an additional container:
section { width: 200px; outline: 1px dotted red; height: 100px; /* no position */ margin: auto; } section:after { content: ""; position: absolute; left: 0; right: 0; margin-top: -50px; /* same as height */ height: 50px; background: silver; opacity: 50%; } div { position: relative; width: 100%; height: 100%; }
<section> <div></div> </section>
If the height is dynamic, then in the example above you can (with caution) use transform translate instead of margin-top . With care - due to the fact that the space on the block will remain at the bottom and in the case of the end of the positioned container will lead to a void below.
widthproperty)? - Vadim Ovchinnikov