请阅读以下代码:
<div style=”width:400px;height:200px;”> <span style=”float:left;width:auto;height:100%;”> <i style=”position:absolute;float:left;width:100px;height:50px;”>hello</i> </span> </div>
问题:span标签的width和height分别为多少?
<div style=”width:400px;height:200px;”> <span style=”float:left;width:auto;height:100%;”> <i style=”position:absolute;float:left;width:100px;height:50px;”>hello</i> </span> </div>
width = 0px,height = 0px
width = 400px,height = 200px
width = 100px,height = 50px
width = 0px,height = 200px
这个时候我们看子元素<i>,它设置了position: absolute;同样脱离的文档流,它并不会影响父元素,所以span 的width:0px;