解决position:fiexd相对父元素定位
作者:互联网
设置position:fiexd之后
不设置top,bottom,left,right位置样式,
通过margin间接调整
复制代码就是开干
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <title>Document</title> <style> .father { width:300px; height:300px; margin-top: 200px; margin-left: 200px; background:green; } .son { position:fixed; margin-top: 140px; width:150px; height:150px; background:red; word-break: break-all; } </style> </head> <body> <div class="father"> <div class="son"> son </div> </div> <p style="height:10000px"></p> </body> </html>
标签:定位,top,fiexd,height,background,position,margin,150px 来源: https://www.cnblogs.com/ll15888/p/13331173.html