当前位置:编程学习 > html/css >>

请问在html中用css布局 怎么把两个div并排用float吗!怎么用!1谢谢

补充:<!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> <style> div{border:2px solid #0066FF; width:950px; height:3000px; margin:auto; padding:inherit;} .bx1{ border-left:none;} .bx2{border-right: none;} .bx3{ border-top: none;} .bx4{border-bottom:none;} .bt{width:950px; height:60px ; } .dh{width:inherit; height:30px; } .sp{width:200px; height:200px;margin:2px 2px ;} .zx{float:left;width:730px; height:200px; border-right:2px solid #0000FF; border-top:2px solid #0000FF;} </style > </head> <body> <div> <div class="bt bx1 bx3 bx2">hu</div> <div class="dh bx1 bx3">hu</div> <div class="sp">hu</div> <div class="zx">hu</div> </div> </body> </html> div并排
追问:<style>
div{border:2px solid #0066FF; width:950px; height:3000px; margin:auto; padding:inherit;}
.bx4{border-bottom:none;}
.bt{width:950px; height:60px ; }
.dh{width:inherit; height:30px; }
.sp{width:200px; height:200px;margin:2px 2px ;}
.zx{float:left;width:730px; height:200px; border-right:2px solid #0000FF; border-top:2px solid #0000FF;}
</style >
怎么不上去!哪里错了!还是不行
答案:楼上没说明白啊,如果照楼上说的,是没法解决问题的。
两个div并排,需要css两个属性,一个是float,一个是width.
也就是说,要分别设置这两个div的浮动方向和宽度。
比如,这两个并排的div放在一个长1000px的div里,那么一个的宽度是400px,另一个是600px,两个div的长度不能超过1000px,否则就浮动到下面去了。
css可以这么写:
div. left { float : left; width:400px;}
div. right { float : right; width:600px;}
当然这是个例子,你可以自己修改宽度,但是不能超过容器的宽度。
其他:百度搜索_css div 并排
http://www.zzzyk.com/zzzyk?word=css%20div%20%B2%A2%C5%C5&tn=myie2&ch=3 用float就行!
float 属性定义元素在哪个方向浮动。
一般在div里面写上float:right;  或者float:left;就可以   是 右浮动  左浮动的意思
div{
  float:right;
  }

上一个:php套在html中具体步骤怎么做,我用的DIV+css
下一个:css中div的基本问题

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,