关与DIV+CSS布局的一些小问题
关与DIV+CSS布局的一些疑惑
<!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>无标题 1</title>
<style type="text/css">
#main
{
background:aqua;
float:left;
width:910px;
height:260px;
}
#left
{
border:#d2e8f3 1px solid;
margin:0px 10px 0px 0px;
float:left;
padding:2px;
width:698px;
height:260px;
}
#right
{
float:left;
width:200px;
height:260px;
background:blue;
}
</style>
</head>
<body>
<div id="main">
<div id="left"></div>
<div id="right"></div>
</div>
</body>
</html>
这段代码为什么那个right的DIV会到左下面去了呢。。。我要的效果是应该是一行排开的。。。
请帮忙,谢谢
------解决方案--------------------好好看看框模型,你现在可以把padding去掉或者margin改小
------解决方案--------------------#left
{
border:#d2e8f3 1px solid;
margin:0px 10px 0px 0px;
float:left;
width:698px;
height:260px;
}
#right
{
float:right;
width:200px;
height:260px;
background:blue;
}
------解决方案--------------------HTML code
<!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>无标题文档</title>
</head>
<body>
<style type="text/css">
#main
{
width:914px;
background:aqua;
float:left;
height:260px;
}
#left
{
margin:0px 10px 0px 0px;
padding:2px;
width:698px;
border:#d2e8f3 1px solid;
float:left;
height:260px;
}
#right
{
width:200px;
float:left;
height:260px;
background:blue;
}
</style>
<div id="main">
<div id="left">10px(margin-right)+2*2px(padding)+1*2px(border)+698px=714px</div>
<div id="right">200px,总共914px</div>
</div>
</body>
</html>