您的位置:首页 > 其它

margin的值为百分比时,4个外边距的值都是参照其包含块的宽度进行计算的

2014-08-07 17:17 246 查看
<!DOCTYPE html>
<html>
<head>
<title>This is Title</title>
<meta charset="UTF-8">
<style>
*{margin:0;padding:0;}
div{width:500px;height:300px;background:red;border:1px solid #000;}
/*margin:150px 150px 150px 150px;*/
p{background:green;margin:30% 30%;width:200px;}
</style>
</head>
<body>
<div>
<p>Hello World</p>
</div>
</body>
</html>

些时,p元素的margin相当于margin:150px 150px 150px 150px;而不是margin:150px 90px 150px 90px;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐