标签:pre div strong 垂直 nsf 水平垂直 osi 垂直居中 str
居中:分位水平居中和水平垂直居中。
1.水平居中
margin:0 auto;
2.水平垂直居中
1 定义两个盒子------wrapper和 .header 2 .wrapper{ 3 background: pink; 4 width:100px; 5 height:200px; 6 position:relative; 7 } 8 .header{ 9 background:red; 10 width:50px; 11 height:50px; 12 position:absolute; 13 left:50%; 14 top:50%; 15 transform:translate(-50%,-50%); 16 17 }
····················
.wrapper{ background: pink; width:100px; height:200px; position:relative; } .header{ background:red; width:50px; height:50px; position:absolute; left:0; top:0; right:0; bottom: 0; margin: auto; }
标签:pre div strong 垂直 nsf 水平垂直 osi 垂直居中 str
原文地址:https://www.cnblogs.com/alaner/p/9564576.html