父元素设置宽时的代码
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
* {padding:0; margin:0;}
/*.container {width:300px; height:300px; background:red;}*/
.item {width:200px; height:200px; background:red;}
p {width:10%; height:100px; background:black;}
</style>
</head>
<body>
<div class="container">
<div class="item">
<p></p>
</div>
</div>
</body>
</html>
父元素没有设置宽时的代码
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
* {padding:0; margin:0;}
.container {width:200px; height:200px; background:red;}
p {width:10%; height:100px; background:black;}
</style>
</head>
<body>
<div class="container">
<div class="item">
<p></p>
</div>
</div>
</body>
</html>
而是相对于“最近被设置宽高的祖先元素”吧。这样理解是否正确?
相对于“最近被设置宽高的祖先元素”吧