Skip to content

Commit 2caa8aa

Browse files
committed
relative+absolute: 💬 added
1 parent c0b7689 commit 2caa8aa

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

README.md

+15
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,18 @@ When you specify **position:absolute**, the element is **removed from the docume
2828
Notice that this time, since div-1a was **removed from the document**, the other elements on the page were **positioned differently: div-1b, div-1c, and div-after moved up since div-1a was no longer there**.
2929

3030
Also notice that div-1a was positioned in the top right corner of the page. It's nice to be able to position things related to the page, but it's of limited value.
31+
32+
33+
## position:relative + position:absolute
34+
35+
If we set **relative positioning** on div-1, any elements within div-1 will be positioned relative to div-1. Then if we set **absolute positioning** on div-1a, we can move it to the top right of div-1:
36+
37+
#div-1 {
38+
position:relative;
39+
}
40+
#div-1a {
41+
position:absolute;
42+
top:0;
43+
right:0;
44+
width:200px;
45+
}

styles/relative.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@
2121

2222
position: relative;
2323
top: 10px;
24-
left: 20px;
24+
right: 0px;
2525
}

0 commit comments

Comments
 (0)