English 中文(简体)
1. 扩大基于其子女的iv
原标题:Extend a div width based on its children width

这里我没有什么问题(这里的价值就是这样说):

Lets say I have a window with a width around 500px. Inside my document, I have an outer div with no specified width, but the following css:

.outer{
  white-space:nowrap;
  background:blue;
}

除此以外,还有3个拥有以下财产的小区:

.t1{
  display:inline-block;
  width:400px;
}

(notice the width of 400px. That s where the problem is, the line is wider than the window, and the outer div does not extend. The HTML looks like that:

<div class="outer">
    <div class="t1">1</div>
    <div class="t1">2</div>
    <div class="t1">3</div>
</div>

我想要达到的是,在不为<代码>t 1类别规定的情况下,有3个内聚四。 这一范例将产生一种蓝色背景,仅限于窗户的宽度。

See full example here: (如果你的屏幕大小,就必须调整底层左上角。)

我很想知道,在不确定外围宽度/内干线背景的情况下,是否只有ru才能达到。

最佳回答
问题回答

增加超支:隐蔽;宽:100%;

解释@thirtydot的答复,

差异是组成部分:

整级元素总是在新线上起步,并覆盖全部可用宽度(在左边和右边挖掘)。

因此,在缺席的情况下,父母的 w是100%。 如果您将这一改动改为inline-blockinline 你会取得你想要的效果。

一条直线要素并不从新的一线开始,而只是在必要的情况下才算起。





相关问题
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....

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

Drop down background url in Safari Issue

selectBox.selectCSS { background: url(/Images/replacementSelectBackground.png) top left no-repeat height:auto; } I have an issue in Safari only where the image is not rendering on top ...

CSS specific for Safari

How do you target specifically safari in css with styles?

Aligning textarea in a form

Ive used the following css code to align my form elements: form { position:relative; } form input { position:absolute; left:11em; } However, the textarea element is not aligned correctly with the ...

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

CSS problem with page footer

I have defined my page footer in the css file as: #footer { position: absolute; height: 50px; text-align: center; background: #66CCCC; bottom: 0px; left: 0px; width: 100%; height: ...

热门标签