码迷,mamicode.com
首页 > Web开发 > 详细

css3固定居中

时间:2017-02-11 11:11:02      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:tom   text   html   doc   css   idt   body   utf-8   style   

<!DOCTYPE html>
<html>
<head>
<title>左右垂直居中</title>
<meta charset="utf-8">
<style type="text/css">
/* div{
width: 250px;
height: 250px;
background-color: red;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}*/
div:nth-child(1){
width: 100px;
height: 100px;
background-color: green;
position: absolute;
/*calc css中可以计算的参数calc(计算表达式) 注意:运算符前后必须有空格 否则无效*/
top:calc(50% - 50px);
left: calc(50% - 50px);
}
</style>
</head>
<body>
<!-- <div></div> -->
<div></div>
</body>
</html>

css3固定居中

标签:tom   text   html   doc   css   idt   body   utf-8   style   

原文地址:http://www.cnblogs.com/adialike/p/6388659.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!