xhtml css 浮动等帮助

发布于 2024-08-01 18:54:58 字数 1116 浏览 1 评论 0原文

我真的很想回到桌子上,因为这只是 #¤€&/@£ 总是一些东西......

<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 条评论,则不会

忽略愚蠢的评论

I'm really thinking of going back to tables because this is just #¤€&/@£ always something....

<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>

This gives:
http://i29.tinypic.com/2iawh83.png

A huge space in the first div. why? it dont if theres more than 10 comments for some reason

ignore the stupid comments

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

書生途 2024-08-08 18:54:58

如果你使用 IE6,使用 20% 和 80% 经常会导致行溢出,我通常使用 20% 79%,你应该可以

看看它是否溢出,尝试添加溢出:隐藏到 div 中,看看是否他们排队,如果是这样,你就知道里面有东西溢出了。

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

if you are using IE6 using 20% with 80% with will often cause the line to overflow, i usually use 20% 79% and you should be ok

to see if it is something overflowing try adding overflow:hidden to the divs and see if they line up, if so you know its something overflowing.

have you used firebug or another inspection tool to see what the heights and widths actually are?

岁吢 2024-08-08 18:54:58

尝试在浮动 div 周围添加一个包装 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 包裹在所有内容中,这只是为了使代码在结构上更有意义。

Try adding a wrapper div around your floating ones. This is just to see if anything above this is affecting it somehow.

<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>

Also I wouldn't make a div just to display a line, but that's another issue entirely. Maybe try a HR tag, or wrap that div around everything, this is just to make the code make more sense structurally.

纵情客 2024-08-08 18:54:58

我会小心地将 20% 和 80% 的宽度期望放在一行上:如果有任何填充或边框,它们就不会。 它看起来应该是 ff 3 中的样子。:D

I would be careful about having width of 20% and 80% expect to fit on one line: if there is any padding or border they won't. It looks the way it should in ff 3. :D

感情废物 2024-08-08 18:54:58

将您的 HTML 粘贴到我的 generic testing-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。

Pasting your HTML into the body of my generic testing-HTML-code-from-Stack-Overflow file:

<!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>

shows no problem. Your problem must lie elsewhere, like in your CSS for instance.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文