CSS Position fixed | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

CSS Position fixed

Why do we not need to set the horizontal position on the span element? <!DOCTYPE html> <html> <head> <title>positin fixed</title> </head> <body> <div style="background:blue;height:84px;width:84px">one <span style="background:red;position:fixed;margin-top:42px;">two</span> </div> </body> </html>

22nd Mar 2017, 12:09 PM
Thomas Zenglein
Thomas Zenglein - avatar
2 Answers
+ 5
Ask for what? While margin-top is the answer! position:fixed is no need then
22nd Mar 2017, 1:07 PM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
- 1
maybe because fixed elements has default x,y position = 0
22nd Mar 2017, 12:18 PM
Yaroslav Pieskov
Yaroslav Pieskov - avatar