html - Positioning a nested DIV relative to the page and not the first positioned ancestor -


is there way position nested div (or other nested html element) relative page (so 0,0 put @ top left of page) when has positioned ancestor, without using javascript.

using position:fixed won't work because positions relative viewport, not move if page scrolled.

using position:absolute won't work since asking nested div positioned ancestor. cause position relative positioned ancestor.

no, can't done without script ...

... unless outer element's left/top position known/fixed, in example

.nr1,  .nr2 {    position: absolute;    width: 300px;    height: 100px;  }    .nr1 {    left: 50px;    top: 50px;    background: red;  }  .nr2 {    left: 0;    top: 0;    background: blue;    margin: -50px 0 0 -50px;  }
<div class="nr1">    <div class="nr2">    </div>  </div>


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -