gpt4 book ai didi

css - 固定宽度元素左侧的动态全宽容器内的全宽输入

转载 作者:行者123 更新时间:2023-11-28 16:03:00 24 4
gpt4 key购买 nike

有点难以在标题中解释......但基本上我需要右侧的元素(搜索按钮)具有固定宽度。左侧的元素填充其余空间。

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演示问题。

如果您将鼠标悬停并观察光标的变化,或者如果您键入以填写它,您可以看到输入结束的位置。

最佳答案

分配display: flex;给你的.ric-search-input-group上课,然后给你 <input>一个flex-grow: 1; .

CSS

.ric-search-form .ric-search-input-group {
display: flex;
}

.ric-search-form .ric-search-input-group input {
flex-grow: 1;
}

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>

JSFiddle

关于css - 固定宽度元素左侧的动态全宽容器内的全宽输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39731975/

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