使用CSS样式 clear:both 实现div不并排
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
#wai{
width:500px;
height:500px;
background-color: #990;
}
#nei {
float:left;
width:200px;
height:200px;
background:#FFF;
}
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
</style>
</head>
<body>
<div id="wai">
<div id="nei">我在左边</div>
<div style="clear:both">我不在右边</div><!--删除红色的字看看-->
</div>
</body>
</html>
相关文档:
屏蔽IE浏览器(也就是IE下不显示)
*:lang(zh) select {font:12px !important;} /*FF,OP可见,特别提醒:由于Opera最近的升级,目前此句只为FF所识别*/
select:empty {font:12px !important;} /*safari可见*/
这里select是选择符,根据情况更换。第二句是MAC上safari浏览器独有的。仅IE7与IE5.0 ......
对DIV+CSS偶还是新手,所以对ID与CLASS之间的区别,偶到今天也还是有些许迷茫,刚才查了下相关资料,果然给偶指明了方向,下面是它们之间的区别来自网上内容我把它收藏了进来,以便参考:
一、在web标准中是不容许重复ID的,例如 div id="a" 不容许重复2次;而class所定义的是类,理论上可以无限重复。以根据需要多次引用 ......
效果图
代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Scrollable</title>
<mce:script type="text/javascript"><!--
resizeCallback = function() {
......
ie6中div的高度自动设置,到了ie7和ie8就不行了,需要设置css
/*针对非IE*/
div:after {
content:".";
display:block;
height:0;
clear:both;
visibility:hidden;
}
/*针对IE*/
div{zoom:1;} ......
强制不换行
div{
white-space:nowrap;
}
自动换行
div{
word-wrap: break-word;
word-break: normal;
}
强制英文单词断行
div{
word-break:break-all;
}
源地址:http://www.iwms.net/n1919c40.aspx
......