html - 拉伸(stretch)输入文本以填充它所在的分区

标签 html css

我有一个包含标签和输入文本的 HTML div。我希望标签占用最小空间,并将剩余空间留给文本输入。换句话说,一旦标签占据了它的空间,我希望文本输入水平延伸到它所在的 div 的末尾。这是我正在使用的示例代码。

<div>
    <label >Some Label</label>  <!--Should take minimum space -->
    <input type="text"/>        <!--Should stretch horizontally to fill up entire div --> 
</div>

最佳答案

demo here

不完美,但你可以尝试在其中实现

我找到了这段代码

<div class="notificationArea">
    <label >Some Label</label>  
    <input type="text"/>
</div>

这里是CSS

.notificationArea
{
    width: 100%;
    vertical-align: left;
    text-align:left;
    background: #ccc;
    display: table;
}
.notificationArea label, .notificationArea input {
    display: table-cell
}
.notificationArea input {
    width: 100%
}

关于html - 拉伸(stretch)输入文本以填充它所在的分区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7020879/

相关文章:

html - 滑动导航栏菜单未全宽显示

javascript - Webassembly 最终会在浏览器中呈现为 HTML 吗?

html - 使用 CSS,如何在悬停时在原始顶部显示另一个 div

javascript - 选择多个 tr 并在单次 tr 单击时重定向

html - 将 div 放在其他 div 的下方,同时向右浮动

javascript - 固定页脚在动态相同大小的 div/列中

php - 转换 BBCode 文本时检查图像大小

html - 在响应式中添加 Bootstrap 页脚

html 选择箭头外观

css - 如何在保持 webkit-box-shadow 的同时使图像具有填充?