gpt4 book ai didi

css - 如果容器宽度不够,如何使 HTML 元素不跨到第二行?

转载 作者:太空宇宙 更新时间:2023-11-04 13:09:22 24 4
gpt4 key购买 nike

我正在动态添加文本框和选择元素,在占据容器标签的整个宽度之后,一个被添加到第二行。但是我不想要第二行,如果容器的宽度不足以容纳所有标签,我应该得到一个水平滚动条

enter image description here

<div class="addContainer">    
<label class="select ">
<select class="form-control" name="selecname" placeholder="" id="id1">
<option value="1">Pass</option>
<option value="0">Fail</option>
</select><i></i>
</label>
<label class="select ">
<select class="form-control" name="selecname" placeholder="" id="id1">
<option value="1">Pass</option>
<option value="0">Fail</option>
</select><i></i>
</label>
<label class="select ">
<select class="form-control" name="selecname" placeholder="" id="id1">
<option value="1">Pass</option>
<option value="0">Fail</option>
</select><i></i>
</label>
<label class="select ">
<select class="form-control" name="selecname" placeholder="" id="id1">
<option value="1">Pass</option>
<option value="0">Fail</option>
</select><i></i>
</label>
<label class="select ">
<select class="form-control" name="selecname" placeholder="" id="id1">
<option value="1">Pass</option>
<option value="0">Fail</option>
</select><i></i>
</label>
<label class="select ">
<select class="form-control" name="selecname" placeholder="" id="id1">
<option value="1">Pass</option>
<option value="0">Fail</option>
</select><i></i>
</label>
<label class="select ">
<select class="form-control" name="selecname" placeholder="" id="id1">
<option value="1">Pass</option>
<option value="0">Fail</option>
</select><i></i>
</label>
<label class="select ">
<select class="form-control" name="selecname" placeholder="" id="id1">
<option value="1">Pass</option>
<option value="0">Fail</option>
</select><i></i>
</label>
<label class="select ">
<select class="form-control" name="selecname" placeholder="" id="id1">
<option value="1">Pass</option>
<option value="0">Fail</option>
</select><i></i>
</label>
<label class="select ">
<select class="form-control" name="selecname" placeholder="" id="id1">
<option value="1">Pass</option>
<option value="0">Fail</option>
</select><i></i>
</label>
<label class="select ">
<select class="form-control" name="selecname" placeholder="" id="id1">
<option value="1">Pass</option>
<option value="0">Fail</option>
</select><i></i>
</label>
<label class="select ">
<select class="form-control" name="selecname" placeholder="" id="id1">
<option value="1">Pass</option>
<option value="0">Fail</option>
</select><i></i>
</label>
<label class="select ">
<select class="form-control" name="selecname" placeholder="" id="id1">
<option value="1">Pass</option>
<option value="0">Fail</option>
</select><i></i>
</label>

这是演示链接 http://jsfiddle.net/5mwFL/

最佳答案

你可以这样试试:<强> DEMO

CSS:

div {
width:600px;
height:60px;
display:block;
white-space:nowrap;
overflow:auto;
}
input {
height:26px;
margin-right:5px;
border:1px solid;
}

HTML:

<div>
<input type="text" />
<input type="text" />
<input type="text" />
<input type="text" />
<input type="text" />
<input type="text" />
<input type="text" />
<input type="text" />
<input type="text" />
<input type="text" />
<input type="text" />
<input type="text" />
<input type="text" />
<input type="text" />
<input type="text" />
<input type="text" />
<input type="text" />
<input type="text" />
<input type="text" />
<input type="text" />
<input type="text" />
<input type="text" />
</div>

关于css - 如果容器宽度不够,如何使 HTML 元素不跨到第二行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24800327/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com