父元素的宽度固定了,它的子元素可以可以改变其父元素的宽度吗?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<title> 无标题文档 </title>
<style type= "text/css ">
#a{
width:200px;
border: 1px solid #FF0000;
}
#b{
margin:10%;
width:100px;
}
</style>
</head>
<body>
<div id= "a ">
<p id= "b ">
This is a paragraph; This is a paragraph; This is a paragraph;
This is a paragraph; This is a paragraph;
This is a paragraph; This is a paragraph;
</p>
</div>
</body>
</html>
上例中, <div> 是 <P> 的父元素,可是我发现 <p> 的margin属性或者width属性改变后,均会对其父元素 <div> 造成影响。为什么?书上《CSS权威指南》不是说了父元素的宽度决定了子元素的宽度吗? 为什么会这样?
到底父元素与子元素的宽度,高度存在什么样的约束关系?
------解决方案--------------------可以撑大~~~