I am trying to position a list item based on a viewport, but they end up sticking to their parents.
To reproduce the problem, I just need to create a list with an absolutely placed element:
body { background-color: lightgray; } ul { position: absolute; top: 50px; left: 50px; list-style: none; } .element { position: absolute; top: 0; left: 0; background-color: red; }
<ul> <li> <div class="element"> <p> Element </p> </div> </li> </ul>
As you can see, the element is not located in the upper left corner of the viewport, but instead relative to ul .
Am I missing something? Could this be the static position of the li elements?
source share