xhtml css浮动等帮助

时间:2009-08-09 00:39:39

标签: html css xhtml css-float

我真的想回到牌桌,因为这只是#¤€& / @£总是......

<div style="float: left; width: 20%">
 #1 <a>SmokA</a><br />
 <small>Admin</small><br />
 <small>2009-08-07</small>
</div>

<div style="float: right; width: 80%">
 I would buy a boat
</div>

<div style="clear:both"></div>

<div style="border-top: 1px solid #071946; border-bottom: 1px solid #1D3060"></div>


<div style="float: left; width: 20%">
 #2 <a>BusHka</a><br />
 <small>Old school</small><br />
 <small>2009-08-07</small>
</div>

<div style="float: right; width: 80%">
 <a href="#comment1">#1</a> is stupid
</div>

<div style="clear:both"></div>
<div style="border-top: 1px solid #071946; border-bottom: 1px solid #1D3060"></div>

这给出了: http://i29.tinypic.com/2iawh83.png

第一个div中的巨大空间。为什么?如果由于某种原因超过10条评论

忽略愚蠢的评论

4 个答案:

答案 0 :(得分:0)

我要小心,宽度为20%,80%预期适合一条线:如果有任何填充或边框,则不会。它看起来应该如何在ff 3.:D

答案 1 :(得分:0)

将HTML粘贴到我的通用测试 - HTML-code-from-Stack-Overflow文件的正文中:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<title>Test</title>
</head><body>
<!-- Rebadow's code here -->
</body></html>

显示没问题。你的问题必须在其他地方,例如你的CSS。

答案 2 :(得分:0)

如果你使用IE6使用20%和80%,通常会导致线路溢出,我通常使用20%79%你应该没问题

看看是否有溢出的东西尝试添加溢出:隐藏到div并查看它们是否排成一行,如果是这样你知道它的东西溢出。

您是否使用过firebug或其他检查工具来查看实际的高度和宽度?

答案 3 :(得分:0)

尝试在浮动广告周围添加包装div。这只是为了看看是否有任何影响它的方式。

<div style="clear:both">
<div style="float: left; width: 20%">
 #1 <a>SmokA</a><br />
 <small>Admin</small><br />
 <small>2009-08-07</small>
</div>

<div style="float: right; width: 80%">
 I would buy a boat
</div>    
</div>

<div style="clear:both"></div>

<div style="border-top: 1px solid #071946; border-bottom: 1px solid #1D3060"></div>

此外,我不会仅仅为了显示一条线来制作一个div,但这完全是另一个问题。也许尝试使用HR标签,或者将div包装在所有内容中,这只是为了让代码在结构上更有意义。