【发布时间】:2015-01-27 22:58:18
【问题描述】:
我将输入组 <div> 包装器设置为 display:table; 与所有内容 display:table-cell; 当我想在桌子上具有固定宽度时,如果我想加宽/缩短单元格以占用剩余部分例如,宽度是 <span> 元素或 <ul> 元素,然后设置 width:100%; 有效。但是,如果元素是 <input> 或 <button>,那么这在 firefox 或 chrome 中不起作用(但在 IE 中起作用),结果是元素占用了输入组的整个空间,将下一个元素向下推到新的一行。我可以通过将<input> 或<button> 放在<span> 元素中并在两者上设置width:100%; 来解决这个问题,但我宁愿有一个css 解决方案。
<div class="input-group wide">
<input type="text" style="width:100%;"></input>
<button>S</button>
</div>
css:
.input-group {
display:inline-table;
padding:0px;
background-color: grey;
}
.input-group > input, .input-group > button, .input-group > span, .input-group > ul {
display: table-cell;
margin:0px;
}
.wide {
width: 260px;
}
【问题讨论】:
-
我认为您仅限于使用包装器(例如跨度)。见stackoverflow.com/questions/15625878/…