简体   繁体   English

如何用html中的剩余宽度填充标签?

[英]How to fill a tag with remaining width in html?

I am trying to make in 1 line, an input and two buttons.我正在尝试制作 1 行、一个输入和两个按钮。 The two button's width should wrap the content, and then the input should fill the width of its parent.这两个按钮的宽度应该包裹内容,然后输入应该填充其父级的宽度。 This is what I have currently这是我目前所拥有的

        <input id="input-field" style="display:inline-block; width:60%;"></input>
        <button id="sticker-button" style="display:inline-block;">☺</button>
        <button id="send-button" style="display:inline-block;">➤</button>

But I can't find the css to make a input tag fill the remaining width.但是我找不到使输入标签填充剩余宽度的 css。 Currently I just put 60%, but this clearly does not work.目前我只放了 60%,但这显然行不通。 Like if this was android, I would have the buttons width be wrap_content and the input's width be fill_parent .就像如果这是 android,我会让按钮宽度为wrap_content ,输入的宽度为fill_parent

Does anyone know how to do this?有谁知道如何做到这一点?

Thanks谢谢

I solved it with this我用这个解决了

        <div style="display:flex;">
            <input id="input-field" style="width:100%;"></input>
            <button id="sticker-button">☺</button>
            <button id="send-button">➤</button>
        </div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM