请阅读以下代码:
1
2
3
4
5
|
< 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 分别为多少?
width = 0px,height = 0px
width = 400px,height = 200px
width = 100px,height = 50px
width = 0px,height = 200px
span 是行内元素 原本width/height是无效的
float之后 脱离文档流的同时 也让他变为块级元素
设置width:auto 取决于撑开span的标签 而原本该撑开它的i标签也设置position:absolute 所以没有标签可以撑开span
所以width 就是0
height:100%则是继承 div的