+ 8

How to give elements relative absolute position ?

I created a div and want all the elements inside it to be positioned absolute but to the div not to the whole page.

13th Mar 2017, 5:22 AM
Utkαrsh
Utkαrsh - avatar
3 Réponses
+ 5
Let's say your div has two <p> elements inside it. This is how the positioning will go div { position: relative; } p { position: absolute; } Now, the p elements are absolute with respect to their parent, which is the div element.
13th Mar 2017, 10:17 AM
Aarthi Sri
+ 13
<style> div{ position: absolute; } <\style>
13th Mar 2017, 6:01 AM
Mansi Dagla
Mansi Dagla - avatar
+ 2
If the parent div has position: relative, it will be positioned relative to parent.
13th Mar 2017, 5:25 AM
spotbot2k
spotbot2k - avatar