Html DIV 内两个按钮之间的间距
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25177435/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Spacing between two buttons inside a DIV
提问by Nagaraj C K
I have a DIV which contain some buttons. I want 16px spacing between these buttons inside this DIV. Can someone please tell me how to do this?
我有一个包含一些按钮的 DIV。我希望此 DIV 中的这些按钮之间的间距为 16 像素。有人可以告诉我怎么做吗?
回答by Youness
in the css :
在 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*/
}
give that css class to the div :
将该 css 类赋予 div :
<div class="Container "><input........</div>
回答by ovunccetin
You can use margin-right
as follows:
您可以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>
回答by blurstream
this could be your scenario:
这可能是你的场景:
<div>
<input style="margin-right: 16px" type="submit">
<input style="margin-right: 16px" type="submit">
<input style="margin-right: 16px" type="submit">
</div>
each submit button has a margin right of 16px for the next one.
每个提交按钮都有一个 16px 的边距供下一个按钮使用。
回答by Dan Bartlett
Set up a div, float the buttons and then add a margin on the first button
设置一个 div,浮动按钮,然后在第一个按钮上添加边距
<div>
<a class="button_1">
<a class="button_2">
</div>
CSS:
CSS:
div a {
float: left;
}
div .button_1 {
margin-right: 16px;
}
回答by Kheema Pandey
回答by Arjjun
Here is a JSX example: Use margin right css tag
这是一个 JSX 示例:Use margin right css tag
-`
<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>`
(margin top and margin right) mt- mr comes from cssbootstrap. Find more here https://getbootstrap.com/docs/4.0/utilities/spacing/
(上边距和右边距) mt-mr 来自 cssbootstrap。在这里找到更多https://getbootstrap.com/docs/4.0/utilities/spacing/