当前位置:编程学习 > JAVA >>

《div并排显示??》

<div  id="main" style="width:100%;height:100%;"> 

<div id="left" style="width:169px;height:100%; position:absolute; background-color:#00FFFF; left:242px; top: 19px;" ></div>

 <div id="cen" style="width:352px;height:100%; position:absolute; background-color:#0099FF;left:412px; top: 17px;"></div>

  <div id="right" style="width:352px; height:100%; position:absolute; background-color:#00FF33; left:765px; top: 16px;"></div>

</div>
现在三个DIV并排显示的,是由left属性值决定的,这样是死的,怎样弄成,随浏览器窗口大小(最大化,最小化)的改变而动态改变div的宽高,和各个div间的边距问题。

--------------------编程问答-------------------- 绝对定位去掉 用 float 设置 --------------------编程问答-------------------- float ="left"漂左显示 --------------------编程问答--------------------
引用 2 楼  的回复:
float ="left"漂左显示


我给id为main的div设置,style="margin:0 auto" 不会居中显示,按你说的用float,整个页面居左对齐,我想让三个div居中显示。
可不可以让div的大小(宽高) 随内容的多少动态改变?? --------------------编程问答-------------------- 那就给div就不要设置宽高

  <div id="main"> 
<div id="content"></div> 
<br style="clear:both;" />
</div> 
#main { border:1px solid #999999; background-color:#CCCCCC; height:100%; overflow:hidden;}
#content { float:left;} 

--------------------编程问答--------------------
引用 4 楼  的回复:
那就给div就不要设置宽高
Java code

  <div id="main"> 
<div id="content"></div> 
<br style="clear:both;" />
</div> 
#main { border:1px solid #999999; background-color:#CCCCCC; height:100%; overflow:hidden;}
#……




如何让三个并排的div居中显示?? --------------------编程问答--------------------


<div id="main" style="width:100%;height:100%;">  

<div style="margin:auto;width:90%;float:right; border:1px soild #fff;height:100%;" id="ccc">
   <div id="left" style="width:30%;height:100%;float:left;background-color:#00FFFF; " >          </div>

 <div id="cen" style="width:30%;height:100%; float:left;background-color:#0099FF;"> </div>

  <div id="right" style="width:30%;height:100%;float:left; background-color:#00FF33; "> </div>
</div>
</div>






试试上面这段代码是否可以满足你的要求 --------------------编程问答-------------------- --------------------编程问答-------------------- 哎 main里cent,让后算三个的width,大的div的width就设置为三个width的值! --------------------编程问答-------------------- 一个大Div里面套三个小div三个d<div align="center" float="left"/> --------------------编程问答--------------------
引用 6 楼  的回复:
HTML code


<div id="main" style="width:100%;height:100%;">  

<div style="margin:auto;width:90%;float:right; border:1px soild #fff;height:100%;" id="ccc">
   <div id="left" style="width:30%;height:……



图片滚动的js怎么写呢?? --------------------编程问答-------------------- <style>
.left { width:305px; height:800px; background:url(bg_1.png) no-repeat; float:left;}
.center { width: 331px; height:800px; background:url(bg_2.png) repeat; float:left;}
.right {width: 364px; height:800px; background:url(bg_3.png) no-repeat; float:left;}
.item { width: 298px; height: 300px; background-color:white; margin:21px 10px; padding:1px; }
.down { width: 298px; height: 132px; background-color:white; margin:21px 10px; padding:1px; }
.main { width: 1000px; height:800px;overflow:hidden;}
</style>
<body>
<div class="main" id="demo">
<div class="left"></div>
<div class="center" id="demo1">
        <div class="item"><img src="5cm.JPG"></div>
<div class="item"><img src="b+ab.jpg"></div>
<div class="down"><img src="00.JPG"></div>
</div>
<div id="demo2" style="float:left"></div>
<div class="right"></div>
</div>
</center>
</body>

现在页面这么布局,怎样让那三个图片自下而上滚动???
--------------------编程问答-------------------- 借鉴下
--------------------编程问答-------------------- 就不应该用绝对布局了,需要加上float属性,最好将css代码单独写在另外一个文件中再用


滚动就要加上marquee属性 或者用js --------------------编程问答-------------------- display:inline

  它可以让行内显示为块的元素,变为行内显示,例如
  <div> DIV1 </div>
  <div> DIV2 </div>
  这里DIV1和DIV2分别占一行,但是你给他们加上属性后变了
  <div style= "display:inline "> DIV1 </div>
  <div style= "display:inline "> DIV2 </div>
  DIV1和DIV2这时候显示在同一行了,试试看吧。

给每个div分配所占宽度的百分比 --------------------编程问答-------------------- http://blog.csdn.net/xttxqjfg/article/details/7816978 --------------------编程问答-------------------- 借鉴下,来看看·· --------------------编程问答-------------------- 借鉴下。。 --------------------编程问答--------------------

display: inline-block;
margin: auto;
width: 30%;


这三个div统一的style --------------------编程问答--------------------

float ="left"漂左显示


我给id为main的div设置,style="margin:0 auto" 不会居中显示,按你说的用float,整个页面居左对齐,我想让三个div居中显示。
可不可以让div的大小(宽高) 随内容的多少动态改变??
[/Quote] --------------------编程问答-------------------- main的div
margin-left:auto;
margin-right:auto;
试试 --------------------编程问答-------------------- 用float:left属性,自己慢慢调吧,总会调好的.
补充:Java ,  Web 开发
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,