关于css宽高问题


问题:span标签的width和height分别为多少?

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Bootstrap 实例 - 标签页与胶囊式标签页</title>
</head>
<body>

<div style="400px;height:200px;">
  <span style="float:left;auto;height:100%;">
           <i style="position:absolute;float:left;100px;height:50px;">hello</i>
  </span>
</div>

</body>
</html>
这题考点其实有几个:
1.span标签是行内元素,无法设置宽高的;
2.float会把浮动元素变成块级元素;支持宽高,height:100%;即为,200px,当height为%单位意为:基于包含它的块级对象的百分比高度。所以这里span的height是200px。宽度由内容撑开。
3.i绝对定位脱离了文档流;span元素width设置为auto,所以塌陷为0,高度还是200px。
原文地址:https://www.cnblogs.com/sunmarvell/p/9015359.html