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

CSS样式表
分页显示之超级提速版
兼容多浏览器实现半透明(Opera ie firefox)
解析IE, FireFox, Opera 浏览器支持Alpha透明的方法
utf8和unicode编码究竟是什么关系?有何区别?
XHTML下css+div布局总结 超强推荐
在IE下拖动滚动条时border消失的解决方法
CSS中常用的单位
有关表格边框的css语法整理(1)
中文排版CSS心得
一个针对IE7的CSS Hack
css也疯狂! 用background 插入flash播放器
如何解决下拉菜单被flash覆盖的问题
网页中关闭IE的图像工具栏和XP主题
解决IE升级后Flash线框问题
em px的关系
在iframe中隐藏横向滚动条的方法大全
Iframe自适应其加载的内容高度
固定右栏宽度, 左栏内容先出现同时自适应宽度的布局
IE Bug--浮动对象外补丁的双倍距离的解决方法
解决IE7以下版本不支持无A状态伪类的几种方法

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-28   浏览: 90 ::
收藏到网摘: 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>

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