+ 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.
3 Antworten
+ 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.
+ 13
<style>
div{ position: absolute; }
<\style>
+ 2
If the parent div has position: relative, it will be positioned relative to parent.