html - 需要 2 个 100% 宽度的文本框,分为 2 个(50% x 50%)以及一个提交按钮

标签 html css

我需要将 2 个文本框拉伸(stretch)到 100% 的浏览器宽度,以及一个提交按钮。所有三个都应该在一行中,我试图拉伸(stretch)它但它没有发生......有什么想法吗?

代码:

.search-input{
width:100%;
border:#CCC solid 1px;
}

<div style="float:left; width:auto; margin-right:10px;"><input name="" type="text" class="search-input" /></div>
<div style="float:left; width:auto;"><input name="" type="text" class="search-input" /></div>
<div style="float:left;"><input name="" value="submit" type="button" /></div>

最佳答案

如果你在一行中需要 3 个东西,你甚至不能有一个 width: 100%。 尝试为每个文本使用 40%,为按钮使用 18%,大致如下所示:

HTML

<div>
<input type = 'text' class = 'text item'>
<input type = 'text' class = 'text item'>
<input type = 'button' id = 'button' class = 'item'>
</div>

CSS

.text{
width: 40%;
}
#button{
width: 28%;
}
.item{
display: inline-block;
}

希望有用。

关于html - 需要 2 个 100% 宽度的文本框,分为 2 个(50% x 50%)以及一个提交按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16609149/

相关文章:

javascript - 如何在 jQuery 的自动完成列表中添加固定项?

css - 在 IE8 中缩放字体大小?

JavaScript:onkeyup() 的原始目标

jquery - 在同一页面中多次使用 Grid-A-Licious 插件

html - 面对显示 :flex, 的问题,我应该改用 float

html - 为此按钮创建渐变

android - Android背景前后的奇怪线条

css - Font Awesome 图标不显示

html - 如何在 Html 文件上传中隐藏文本字段

css - Bootstrap v5.1.3 : merge $colors with $theme-colors map