易截截图软件、单文件、免安装、纯绿色、仅160KB

CSS Containing Floats

原文网址:http://www.complexspiral.com/publications
Containing Floats
As powerful and useful as they are, floats can make for tricky layout tools. Chances are that you may have seen something like the situation shown in Figure 1, which is accomplished with just two div elements, each with a floated image inside it.
Figure 1. That's not right!
This is probably not what the author had in mind, but given the styles used, it's the correct layout. Here's how we created it:
div.item {border: 1px solid; padding: 5px;}
div.item img {float: left; margin: 5px;}
That's all it takes. The result seen in Figure 1 happens because the div elements don't "stretch" to contain the floated images within them. To look at the situation from the reverse angle, it happens because the floated images "stick out" of the bottom of the div elements.
This is not a bug. It's also not a flaw in CSS. It is, in fact, the behavior that most authors will want most of the time. It's just not what they would want in the example shown in Figure 1.
Understanding the Problem
So when in the name of all that's good and right would authors want floats to stick out of their containing elements? Simple: in what is historically the most common case for float use. Consider Figure 2, and the basic markup structure that produced it.
Figure 2. Floating an image, flowing the text.
<p>
 ...text...
 <img src="jul31-03-sm.jpg" height="200" border="0" class="picture">
 ...text...
</p>
<p>
 ...text...
</p>
The practice of flowing text around an image goes back a long, long time. That's why the ability was added to the Web starting with Netscape 1.1, and why CSS makes it possible using the property float.[1] But look closely at Figure 2. The floated image is sticking out of its containing element. We can see this more clearly by adding borders to the paragraphs, as shown in Figure 3.
Figure 3. Adding borders to the paragraphs.
So now we can se


相关文档:

css样式相关知识小结

可以放置样式的地方:样式表,<style>和style
样式表是一个独立的文件,可以通过<link>元素或者css的@import语句把它附加到某个html文档中,<style>是一个html元素,可以把它内嵌在html文档中,style是一个属性,可以内置在任何html元素中。
要想把样式表连到html文档中,要在html文档中的<head> ......

ie8 css float问题

#weblmenu
{
height:22px;
width:700px;
float:left;
display:inline;
text-align:left;
}
#weblmenu ul
{
height:22px;
width:700px;
text-align:left;
float:left;
}
#weblmenu ul li
{
height:22px;
width:110px;
float:left;
list-style-type:none;
text-align:center;
word-break:break-all;
} ......

css hack


  IE6 IE7 IE8 Firefox Opera Google
范例
>
Y
Y
N
N
N
N
.type { >color: #F00; }
.
Y
Y
N
N
N
N
.type { .color: #F00; }
*
Y
Y
N
N
N
N
.type { *color: #F00; }
_
Y
N
N
N
N
N
.type { _color: #F00; }
!important
N
Y
Y
Y ......

用div+css解决VS2005中布局难的问题

用div+css解决VS2005中布局难的问题
Div+CSS布局入门教程 《转自 蓝色理想 http://www.blueidea.com/tech/site/2006/3574.asp》
页面布局与规划
在网页制作中,有许多的术语,例如:CSS、HTML、DHTML、XHTML等等。在下面的文章中我们将会用到一些有关于HTML的基本知识,而在你学习这篇入门教程之前,请确定你已经具有了 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号