让设置position为fixed的div剧中的⽅式让设置position为fixed的div剧中的⽅式:
1,交给浏览器⾃适应
左右剧中:
position:fixed;
left:0;
right:0;
margin-left:auto;
margin-right:auto;
或者:
position:fixed;
left:0;
right:0;
div中的div居中margin:auto;
上下居中:
position:fixed;
margin:auto;
top:0;
bottom:0;aa
例⼦:
position:fixed;
top:50px;
z-index:88;
width:1100px;
height:64px;
border:2px solid red;
left:0;
right:0;
margin:auto;
View Code
2,浮动50%再左移动⾃⾝的⼀半
position: fixed;
z-index:1;
top: 50%;
left: 50%;
margin: -141px 00 -201px;
width: 400px;
height:280px;
设置 position: fixed;
设置 left:50% 和 top:50%;
设置 margin: -(DIV的offsetWidth/2) 00 -(DIV的offsetHeight/2)

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。