qq_霸王处秀_0
2015-12-06 09:11
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>背景原点</title>
<style type="text/css">
.wrap {
width:220px;
border:20px dashed #000;
padding:20px;
font-weight:bold;
color:#000;
background:#ccc url(http://static.mukewang.com/static/img/logo_index.png) no-repeat;
background-origin: content-box;
position: relative;
}
.wrap span {
position: absolute;
left:0;
top:0;
}
.content {
height:80px;
border:1px solid #333;
}
</style>
</head>
<body>
<div class="wrap"><span>padding</span>
<div class="content">content</div>
</div>
<br/>
</div>
</body>
</html>.content 未设置width,为什么他有160px左右的宽度
.content 是在div上的,div是一个块级元素,块级元素不设置宽度,默认就是父级元素的宽度,所以他有他的父级元素的内宽度就是220px
十天精通CSS3
243145 学习 · 2677 问题
相似问题