共计 1256 个字符,预计需要花费 4 分钟才能阅读完成。
提醒:本文最后更新于2019-04-20 14:57,文中所关联的信息可能已发生改变,请知悉!
overflow:hidden 自动隐藏超出的字符,图片,防止撑出层和表格的范围
不过你真的理解了这个标签吗?
主要是这个范围 一般我们只考虑了横向的范围,就是定义width 但是没考虑纵向的范围,没定义height 于是不管怎么搞 就是不隐藏,自动换行,后来在调整上下间距的时候,突然想到没定义height 字符所以会跑到换行 赶紧定义height ok了 显示完美了
下边是div实现两列显示没加overflow:hidden时的代码,在ie中查看效果是正常的,但在firefox中右侧的背景和边框会扩展到左侧.
<!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=gb2312" /> | |
<title>firefox中div两列</title> | |
<style type="text/css"> | |
.w {width:400px;} | |
.d1 {height:50px;float:left;} | |
.d2 {height:50px;background:#F9EDFA;border:2px dotted #A63DAD;} | |
</style> | |
</head> | |
<body> | |
<div class="w"> | |
<div class="d1">左侧</div><div class="d2">右侧</div> | |
</div> | |
</body> | |
</html> |
下边是修正后的代码,在firefox和ie中都能正常显示了
<!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=gb2312" /> | |
<title>firefox中div两列</title> | |
<style type="text/css"> | |
.w {width:400px;} | |
.d1 {height:50px;float:left;} | |
.d2 {height:50px;background:#F9EDFA;border:2px dotted #A63DAD;overflow:hidden} | |
</style> | |
</head> | |
<body> | |
<div class="w"> | |
<div class="d1">左侧</div><div class="d2">右侧</div> | |
</div> | |
</body> | |
</html> |
正文完