DIV内两个按钮之间的间距

时间:2014-08-07 08:16:49

标签: html

我有一个包含一些按钮的DIV。我想在这个DIV中的这些按钮之间有16px的间距。有人可以告诉我怎么做吗?

6 个答案:

答案 0 :(得分:9)

在css中:

.Container input{ /* You Can Name it what you want*/
margin-right:16px;
}
.Container input:last-child{
margin-right:0px;
/*so the last one dont push the div thas giving the space only between the inputs*/
}

将该css类提供给div:

<div class="Container "><input........</div>

答案 1 :(得分:3)

您可以按如下方式使用margin-right

<div class='myDiv'>
    <button style='margin-right:16px'>Button 1</button>
    <button style='margin-right:16px'>Button 2</button>
    <button>Button 3</button>
</div>

答案 2 :(得分:0)

这可能是你的情景:

<div>

    <input style="margin-right: 16px" type="submit">

    <input style="margin-right: 16px" type="submit">

    <input style="margin-right: 16px" type="submit">

</div>

每个提交按钮的下一个边距为16px。

答案 3 :(得分:0)

设置div,浮动按钮,然后在第一个按钮上添加边距

<div>
  <a class="button_1">
  <a class="button_2">
</div>

CSS:

div a {
  float: left;
}
div .button_1 {
  margin-right: 16px;
}

答案 4 :(得分:0)

您只需在输入标签上添加保证金即可。查看 DEMO

input[type="submit"]{margin:0 16px;}
input[type="submit"]:last-child{margin-right:0;} /*Remove the margin from last input field*/

答案 5 :(得分:0)

这是一个JSX示例:使用右边距css标签

     -`
          <Link to="#" id="buyButton" className="btn btn-primary mt-2 mr-2">
            Buy this
          </Link>`

          '<Link to="#" id="buyButton" className="btn btn-primary mt-2 mr-2">
           Buy that
          </Link>`

(边距顶部和边距右边)mt-mr来自cssbootstrap。在https://getbootstrap.com/docs/4.0/utilities/spacing/

中找到更多内容