Как расположить вложенный элемент div в абсолютном верхнем левом углу области просмотра, независимо от его предков ⇐ CSS

Разбираемся в CSS
Гость
Как расположить вложенный элемент div в абсолютном верхнем левом углу области просмотра, независимо от его предков

Сообщение Гость »


How do I position a div in the upper left hand corner of the viewport using CSS only?

I know the following doesn't work, since it will not put the element in the top left corner if ancestors of the element have margins and padding:

Код: Выделить всё

.topleft {     position: fixed;     top: 0;     left: 0; } 
I cannot control the ancestors of this element, so I am unable to use any solution that requires controlling or knowing the margins of elements higher in the DOM tree. Javascript is also not allowed.


Источник: https://stackoverflow.com/questions/781 ... -the-viewp

Вернуться в «CSS»