Fin*_*ish 3 html css html5 css3
我试图解决,如果有意做出一个父div调整大小以适应内容有意被阻止包装内容.作为一个例子,这里有一个jsfiddle jsfiddle.net/wtQfV来说明我的问题.
示例代码:
HTML
<div class="box_holder">
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS
.box_holder{
border:1px solid red;
white-space:nowrap;
}
.clearfix{
clear:both;
}
.box{
width:30px;
height:20px;
margin:10px;
background-color:red;
display:inline-block;
}
Run Code Online (Sandbox Code Playgroud)
有没有为此工作或我应该接受我正在追逐彩虹,我需要一个JavaScript解决方案.
Gab*_*oli 11
你也可以把.box_holder元素做好inline-block..
.box_holder{
border:1px solid red;
display:inline-block;
white-space:nowrap;
}
Run Code Online (Sandbox Code Playgroud)
演示http://jsfiddle.net/gaby/wtQfV/5/
如果您希望它在有空间时仍然保持100%的宽度,您可以添加min-width:100%它
.box_holder{
border:1px solid red;
display:inline-block;
min-width:100%;
white-space:nowrap;
}
Run Code Online (Sandbox Code Playgroud)
演示http://jsfiddle.net/gaby/wtQfV/7/
| 归档时间: |
|
| 查看次数: |
7689 次 |
| 最近记录: |