让设置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;
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 0 0 -201px;
width: 400px;
height:280px;
设置 position: fixed; 
设置 left:50% 和 top:50%;
设置 margin: -(DIV的offsetWidth/2) 0 0 -(DIV的offsetHeight/2

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM