【问题标题】:Auto margin for input float left输入浮动的自动边距
【发布时间】:2012-07-13 09:21:16
【问题描述】:
<div style="width:500px">
<input type="text"><input type="text"><input type="text">
</div>

输入的宽度为 31%,我会的,它们以 100% 填充父 div。前两个输入的自动边距。像这样:

【问题讨论】:

    标签: input width margin fill


    【解决方案1】:

    请看下面的代码。

    <div class="container">
    <input type="text"><input type="text"><input type="text">
    </div>
    
    <style type="text/css">
    .container {width:500px;}
    .container input {width:30%;}
    .container input:first-child {margin-right:5%;}
    .container input:last-child {margin-left:5%;}
    </style>
    

    【讨论】:

    • 我试过这个,但它不起作用。在一个浏览器中没问题,但在另一个浏览器中,最后一个输入落在其他浏览器下。我需要一些可以设置自动边距的东西。或者像这样,我将为前两个输入设置边距,例如 10px,所有输入的宽度都是自动的。
    • 能否请您指定这是在哪个浏览器中运行以及在哪个浏览器中无法运行,请不要忘记写浏览器版本。
    猜你喜欢
    • 2014-01-25
    • 2021-09-04
    • 1970-01-01
    • 1970-01-01
    • 2016-05-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多