Moonless.net首页

Cutsin受难记

Home Blog 归宿美林湾 Labs

2008年8月19日星期二

IE6 img边缘的空白以及浮动和inline box

遇到别人提的2个问题,以前虽然经常解决完就算,但真要问到为什么,那时的反应却真可说是呆若木鸡……
1、<div><img></div>为什么在IE6图片的边缘会有空白?
解决的方法有很多:
a.给div设overflow:hidden或font-size:0
b.给img设float或display:block或vertical-align
但究其原因,也许是IE6中<img>始终带有haslayout,而在此情况下IE6对行高和line-box的解释不正确有关

2、这样的结构:<span>text</span><p style="float:right">abc</p>,为什么那个p不是和内联元素在同一行呢?
流行的做法有很多:
a.改成这样的结构:text<p style="float:right">abc</p>
b.让span也浮动
原因呢?其实这是我们对浮动、inline box的概念不清;
和clear相似,w3对float的解释:
The element generates a block box that is floated to the left. Content flows on the left side of the box,

starting at the top (subject to the 'clear' property).
关于inline box本质以及高度的算法:
http://meyerweb.com/eric/css/inline-format.html

标签:

收藏到网摘:新浪VIVI  365Key  POCO网摘  和讯网摘  我摘

0 条评论:

发表评论

订阅 博文评论 [Atom]

<< 主页