代码改变世界

清除浮动(闭合浮动元素)方法总结

2012-08-22 22:35 by youxin, 509 阅读, 0 推荐, 收藏,
摘要:什么是CSS清除浮动?网络上流行的说法是:在非IE浏览器(如Firefox)下,当容器的高度(height) 为auto,且容器的内容中有浮动(float为left或right)的元素,在这种情况下,容器的高度不能自动伸长以适应内容的高度,使得内容溢出到 容器外面而影响(甚至破坏)布局的现象。这个现象叫浮动溢出,为了防止这个现象的出现而进行的CSS处理,就叫CSS清除浮动。出现浮动溢出的条件是什么?首要条件:height:auto,或者说高度是自动伸展的。由于容器里面有float元素,由于float元素是脱离文档流的,所以容器是不能获取float的高度的。看下面的例子: ... 阅读全文

css layout/fixed03: 2 column left navigation

2012-08-22 21:58 by youxin, 357 阅读, 0 推荐, 收藏,
摘要:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso- 阅读全文

css layout/fixed02: 1 column top navigation

2012-08-22 21:40 by youxin, 199 阅读, 0 推荐, 收藏,
摘要:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso- 阅读全文

css layout/fixed01/1 column no navigation

2012-08-22 21:37 by youxin, 252 阅读, 0 推荐, 收藏,
摘要:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso- 阅读全文

css layout :center

2012-08-22 21:33 by youxin, 325 阅读, 0 推荐, 收藏,
摘要:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf- 阅读全文

css :three column +top box

2012-08-22 20:59 by youxin, 394 阅读, 0 推荐, 收藏,
摘要:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf- 阅读全文

css float浮动

2012-08-22 16:07 by youxin, 645 阅读, 0 推荐, 收藏,
摘要:浮动的框可以向左或向右移动,直到它的外边缘碰到包含框或另一个浮动框的边框为止。(这个很重要,说明了浮动停止的条件)由于浮动框不在文档的普通流中,所以文档的普通流中的块框表现得就像浮动框不存在一样。CSS 浮动请看下图,当把框 1 向右浮动时,它脱离文档流并且向右移动,直到它的右边缘碰到包含框的右边缘:再请看下图,当框 1 向左浮动时,它脱离文档流并且向左移动,直到它的左边缘碰到包含框的左边缘。因为它不再处于文档流中,所以它不占据空间,实际上覆盖住了框 2,使框 2 从视图中消失。如果把所有三个框都向左移动,那么框 1 向左浮动直到碰到包含框,另外两个框向左浮动直到碰到前一个浮动框。如下图所示, 阅读全文

利用position:absolute重叠元素

2012-08-22 11:02 by youxin, 921 阅读, 0 推荐, 收藏,
摘要:An absolute position element is positioned relative to the first parent element that has a position other than static. If no such element is found, the containing block is <html>:Absolutely positioned elements are removed from the normal flow. The document and other elements behave like the ab 阅读全文

Absolute, Relative, Fixed Positioning: How Do They Differ?

2012-08-22 10:58 by youxin, 394 阅读, 0 推荐, 收藏,
摘要:I am fairly new to web design and I could never master the differences in positioning of elements. I know there are absolute, fixed, and relative. Is there any others? Also do they majorly differ? And when should you use which?Short answer:Yes, there is one more, "static", which is the def 阅读全文

关于margin-top/bottom在non-Replaced inline元素上不起作用的解释

2012-08-22 10:45 by youxin, 328 阅读, 0 推荐, 收藏,
摘要:margin-top/bottom have no effect on non-replaced inline elements。(参见css2.1规范)但是为什么就不支持呢?本人觉得可以这样解释:像这样一个结构xxxxxxxxxxxxxxxx——————效果大概如下xxxxxxxxxxxxxxx————-假如inline元素支持margin-top,而margin-top的参照基准是前一个元素(当然,考虑复杂情况的话,这么说是不正确的,比如前一元素是脱离文档流的元素,或者根本没有前一元素而只有上级元素,等等)。那么给b相对a的设置一个margin-top值,这个效果会是怎么呢?这样?xxxx 阅读全文
上一页 1 ··· 215 216 217 218 219 220 221 222 223 ··· 269 下一页