English 中文(简体)
1. 具备“视力”
原标题:Have divs "tight fit"
  • 时间:2011-10-31 11:09:57
  •  标签:
  • html
  • css

这是我的超文本结构:

<div> <span>Some text</span> <br/> <span>Not much text</span> </div>
<div> <span>Some text</span> <br/> <span>Not much text</span> </div>
<div> <span>Some text</span> <br/> <span>Not much text</span> </div>

我有三条<条码>div,所有这些编号有2条<代码>span,但文本不一。 我希望所有三条<代码>div上出现。 目前,每条<代码>div 处理一条新线的整个宽度。

我不想code。 如果<代码>divs 如同spans,从这个意义上讲,这些代码的内容(无白色空间)“灯光”。

最佳回答

最容易采用<代码>float留待div,以便其坐在网上。 或者,你可以将<代码>显示:inline-block应用到div,但这只能放在IE8+中。

但我不得不问一个问题,为什么你需要<条码>div 标签? 似乎像你一样,在座为采购处创造更多的工作。

首先,我倾向于采用一个在线要素,例如<代码>span,然后在需要时适用<代码>:inline-block<>>:> for pavention,差额。

问题回答

我不知道为什么每个人都要说<条码>float:left或:inline-block;。 当你说,你希望四分五裂。 这样做的正确方法是:

div {
    display: inline;
}

Ignore anyone saying this:

“如果你想要look 如同一个时期,使用一个十字路口”

说明什么内容应当look as <>/em>,“超文本”指的是什么内容?

我确信,你有选择政党的理由,而且可能更好的选择,但如果没有实际情况,就不可能说。 但<div> and <span>没有实际的语义含义。

违约时,四分之三作为“锁级”要素处理。 区级要素通常含有线性要素和其他组级要素。 在直观的情况下,通常从新线开始。

div {
    display: inline-block;
}

由于有,因此我要说的是,如果你需要一个与另一个要素一样的内容,则可能要作出更适当的选择。

我认为这是你想要的。

    <div style="float:left;padding:2px;"> <span>Some text</span> <br/> <span>Not much text</span> </div>
    <div style="float:left;padding:2px;"> <span>Some text more text</span> <br/> <span>Not much text</span> </div>
    <div style="float:left;padding:2px;"> <span>Some text more more and more text</span> <br/> <span>Not much text</span> </div>

Ignore paids, 它只是要有更好的看法。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!