我希望我的“按名称搜索” #left div扩展整个红色区域:
#main {
border: 1px solid black;
font-size: 20px;
font-weight: bold;
color: white;
}
#left {
width: 100%;
background-color: red;
}
#center {
float: right;
width: 230px;
background-color: blue;
}
#right {
float: right;
width: 45px;
background-color: green;
}
<div id="main">
<div id="right">
<button name="button" type="submit" class="btn btn-default"><i class="glyphicon glyphicon-search"></i></button>
</div>
<div id="center">
<div class="dropdown bootstrap-select show-tick select-picker navbar-margins">
<select name="tag_id[]" id="tag_id_" class="select-picker navbar-margins" data-actions-box="true" data-selected-text-format="count > 1" data-title="No Tags Selected" data-deselect-all-text="Select None" multiple="multiple" tabindex="-98"></select>
</div>
</div>
<div id="left">
<input type="text" name="q" id="q" placeholder="Search by Name or Contact Info">
</div>
</div>
当我添加以下内容以跨越我的#q div时,该元素会降低:
CSS:
#left #q {
width: 100%;
}
停止使用浮点数,而改用flex:
#main {
border: 1px solid black;
font-size: 20px;
font-weight: bold;
color: white;
display: flex; /* use this instead of floats */
}
#left {
flex-grow: 1; /* make this grow to fill remaining space */
}
#left input {
width:100%; /* optional - make the input fill the div */
}
#center {
width: 230px;
background-color: blue;
}
#right {
width: 45px;
background-color: green;
}
<div id="main">
<div id="left">
<input type="text" name="q" id="q" placeholder="Search by Name or Contact Info">
</div>
<div id="center">
<div class="dropdown bootstrap-select show-tick select-picker navbar-margins">
<select name="tag_id[]" id="tag_id_" class="select-picker navbar-margins" data-actions-box="true" data-selected-text-format="count > 1" data-title="No Tags Selected" data-deselect-all-text="Select None" multiple="multiple" tabindex="-98"></select>
</div>
</div>
<div id="right">
<button name="button" type="submit" class="btn btn-default"><i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句