CSS解决 DIV 3列居中难题
2013-05-03 22:44
246 查看
在DIV+CSS中浮动[/b]功能非常的强大,能实现非常复杂的排版问题,2列居中没问题,但是DIV 3列居中经常出现混乱现象。现在为大家提供解决方法。
布局使用的是 左 -右 -中 的方法 ,在IE和Firefox测试没问题,以前书上推荐使用position 但是结果出现排版问题,下面这是我的测试。用颜色标出了。
<!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-8" />
<title>无标题文档</title>
<style type="text/css">
html{ height:100%;width:100%;}
body{ margin:2px ; padding:0px; height:100%;width:100%;}
#box{ width:1000px; margin:auto; padding:0px;}
#left{
height:300px;
background:#0F6;
width:170px;
float:left;
}
#center
{
background:#C69;
height:300px;
margin-left:172px;
margin-right:101px;
}
#right{
height:300px;
width:100px;
float:right;
background:#CC3;
}
</style>
</head>
<body>
<div id="box">
<div id="left"></div>
<div id="right"></div>
<div id="center"></div>
</div>
</body>
</html>
来源:www.21lxj.com
本文出自 “csr0312” 博客,请务必保留此出处http://csr0312.blog.51cto.com/3988257/1192621
布局使用的是 左 -右 -中 的方法 ,在IE和Firefox测试没问题,以前书上推荐使用position 但是结果出现排版问题,下面这是我的测试。用颜色标出了。
<!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-8" />
<title>无标题文档</title>
<style type="text/css">
html{ height:100%;width:100%;}
body{ margin:2px ; padding:0px; height:100%;width:100%;}
#box{ width:1000px; margin:auto; padding:0px;}
#left{
height:300px;
background:#0F6;
width:170px;
float:left;
}
#center
{
background:#C69;
height:300px;
margin-left:172px;
margin-right:101px;
}
#right{
height:300px;
width:100px;
float:right;
background:#CC3;
}
</style>
</head>
<body>
<div id="box">
<div id="left"></div>
<div id="right"></div>
<div id="center"></div>
</div>
</body>
</html>
来源:www.21lxj.com
本文出自 “csr0312” 博客,请务必保留此出处http://csr0312.blog.51cto.com/3988257/1192621
相关文章推荐
- CSS 解决最难的 DIV 3列居中问题
- Div垂直居中及容器内图片垂直居中的CSS解决方法
- 纯css完美地解决图片在div内垂直水平居中,兼容IE7.0、IE6.0、IE5.5、IE5.0、FF、
- 用CSS控制DIV居中失效的解决方法
- 纯css解决position:abusolute的div居中显示
- 解决在IE8浏览器下css+div网页不能居中的问题
- div+css解决图片垂直居中问题
- 解决XHTML中DIV+CSS布局时不能居中的问题
- CSS解决未知高度的DIV垂直居中
- CSS中div垂直居中(包含解决IE兼容问题)
- DIV+CSS中图片和文字居中问题解决方案
- CSS解决未知高度的DIV垂直居中
- CSS解决未知高度的DIV垂直居中
- 兼容IE6,IE7,IE8,Firefox,Chrome,DIV+CSS垂直居中终于失败,最后三分钟用写了几行JS解决,经简单测试,还行。
- CSS解决DIV居中相关问题
- Div垂直居中及容器内图片垂直居中的CSS解决方法
- 【转】CSS解决未知高度的DIV垂直居中
- CSS解决DIV垂直居中的问题
- 解决DIV+CSS在FireFox中的居中问题
- DIV+CSS中图片和文字混排居中问题解决方案