讓設置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