发新话题
打印

同是三行三列,请问有什么不一样?

同是三行三列,请问有什么不一样?

1
--------------------------------------------------------------------------
三行三列

xhtml:

<div id="header">这里是顶行</div>
<div id="warp">
<div id="column">
<div id="column1">这里是第一列</div>
<div id="column2">这里是第二列</div>
<div class="clear"></div>
</div>
<div id="column3">这里是第三列</div>
<div class="clear"></div>
</div>
<div id="footer">这里是底部一行</div>

CSS:

#header{width:100%; height:auto;}
#wrap{ width:100%; height:auto;}
#column{ float:left; width:60%;}
#column1{ float:left; width:30%;}
#column2{ float:right; width:30%;}
#column3{ float:right; width:40%;}
.clear{ clear:both;}
#footer{width:100%; height:auto;}
--------------------------------------------------------------------------


2
--------------------------------------------------------------------------

xhtml:

<div id="header">这里是顶行</div>
<div id="warp">
<div id="column1">这里是第一列</div>
<div id="column2">这里是第二列</div>
<div id="column3">这里是第三列</div>
</div>
<div id="footer">这里是底部一行</div>

CSS:

#header{width:100%; height:auto;}
#wrap{ width:100%; height:auto;}
#column1{float:left;width:30%;background-color: #E1E1E1;}
#column2{float:left;width:30%;background-color: #CCCCCC;}
#column3{float:right;width:40%;background-color: #B7B7B7;}
#footer{width:100%; height:auto;}
--------------------------------------------------------------------------

请问上面的两种方法,除了写法不同以外,在实用方面、效果方面或是其他方面还有什么不同呢?

(顺便问问,在CSS里的方框中的:清除左对齐、清除右对齐、清除两者 各有什么用?我自己搜过这方面的介绍,很可惜的是什么都搜不到,但是又见到很多人都用到清除什么什么的这一项!)

TOP

楼主自己应该去试一下。两者的包含关系不一样,实现效果倒是可能差不多。

TOP

我试过了

我是试过了没发现有什么不同才发上来问问大家有没什么不同之处

(我自己试的时候实现的效果都是一样的,2,是我自己写的,1,是在网上看到的所谓的标准格式)

TOP

呵呵,
第二种结构明显清晰很多,代码也少了,,修改起来也比较方便 (如果把三列改成四列五列或更多,第一种写法是不是就不比第二种方便了?)
xhtml+css图啥?不就是代码简洁一点,,结构清晰一点,,修改起来方便一点,,。

其实没什么标不标准,,好用就是标准。

TOP

发新话题