在标题中很难解释......但基本上我需要右边的项目(搜索按钮)具有固定宽度。左边的项目填充了剩下的空间。
HTML:
<div class="ric-search-form">
<button id="ricSearchButton">Search</button>
<div class="ric-search-input-group"><span class="icon-search8"></span>
<input style="" placeholder="Search" id="ricSearchField">
</div>
</div>
在左侧的项目(.rich-search-input-group
)中,有一个span
和一个input
。如何确保我的input
填满剩下的.rich-search-input-group
?
JSFiddle证明了这个问题。
如果您悬停并观察光标变化或键入以填充它,您可以看到输入结束的位置。
答案 0 :(得分:1)
将display: flex;
分配到.ric-search-input-group
课程,并将<input>
flex-grow: 1;
.ric-search-form .ric-search-input-group {
display: flex;
}
.ric-search-form .ric-search-input-group input {
flex-grow: 1;
}
。{/ p>
<强> CSS 强>
body {
background-color:white;
}
.ric-search-form {
font-family: "Knowledge Regular";
overflow: hidden;
margin-bottom: 23px;
}
.ric-search-form button {
float: right;
width: 120px;
height: 32px;
background-color: #ff8000;
color: #fff;
border-radius: 2px;
border: none;
font-size: 14px;
font-weight: bold;
margin-left: 15px;
}
.ric-search-form .ric-search-input-group {
width: auto;
overflow: hidden;
border-bottom: 1px solid #c8c8c8;
margin-right: 15px;
display: flex;
}
.ric-search-form .ric-search-input-group span {
font-size: 26px;
color: #c8c8c8;
}
[class^="icon-"], [class*=" icon-"] {
font-family: 'icomoon';
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.ric-search-form .ric-search-input-group input {
outline: none;
border: none;
font-size: 28px;
padding-left: 15px;
color: #9b9b9b;
flex-grow: 1;
}
<div class="ric-search-form">
<button id="ricSearchButton">Search</button>
<div class="ric-search-input-group"><span class="icon-search8"></span>
<input style="" placeholder="Search" id="ricSearchField">
</div>
</div>
{{1}}
<强> JSFiddle 强>