当前位置: 首页 > 图文教程 > 网页制作 > CSS样式表 > css浮动的实例

CSS样式表
css position: absolute、relative详解
实用CSS 文字收集
CSS之少用继承,多用组合
IE下href 的 BUG问题
firefox的超链接点击去除扩大的难看虚线的解决方法
css li 超出隐藏代码
多浏览器支持CSS 容器内容超出(溢出)支持自动换行
IE6不能正常解析CSS文件问题的解决方法及原因分析
css 表单效果
div+css模拟表格效果代码
ie6 注释引起的问题
CSS Hack 汇总快查
CSS小例子(只显示下划线的文本框,像文字一样的按钮)
另一个角度谈谈DIV+CSS
单行图片文字垂直居中问题:实战
符合标准的div+css制作的弹出菜单
DIV+CSS常见错误汇总
基本的页面设计元素布局比例
CSS学习者:2008年不要作浮躁的人
关于学习DIV+CSS的一些精妙问答

CSS样式表 中的 css浮动的实例


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-28   浏览: 57 ::
收藏到网摘: n/a

css浮动

结论,非浮动元素可以为后面的浮动元素定位, 但是 浮动元素无法再为其后的非浮动元素定位。

No-float A + Float B + No-float C

c和b 会按照A的边界进行定位,

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><TITLE>CSS TEST</TITLE>
<style type=text/css>
body{
text-align: center;
background: #000;
}
#container{
width:778px;
background: #e3e3e3;
margin:0px auto;
}
#idParentDiv{
width:760px;
margin:0px auto;
text-align:left;
}
#boxleft{
width:200px;
height:80px;
background-color:yellow;
}
#boxmiddle{
float:left;
width:250px;
height:100px;
background-color:red;
}
#boxright{
width:250px;
height:120px;
background-color:blue;
}
</style>
<body>
<div id=container>
        <div id=idParentDiv>
                <div id=boxleft>boxleft---width:200px;height:20px;color:#FFFFFF;background-color:yellow;letter-spacing:0px;  </div>
                <div id=boxmiddle>boxmiddle---float:left;width:250px;height:30px;background-color:red;</div>
                <div id=boxright>boxright----width:250px;height:50px;background-color:blue;</div>
        </div>
</div>
</body>
</html>

点击这里返回本站的 网页设计教程 频道