如何使边距折叠与输入类型=按钮/提交一起工作?
考虑以下代码:
<p style="margin: 30px 0; padding: 0;">Some text some text some text some text some
text some text some text some text</p>
<p style="margin: 30px 0; padding: 0;">Some text some text some text some text some
text some text some text some text</p>
<input type="button" value="Button" style="margin: 30px 0; padding: 0; float: right;"/>
最后一个p30px
边距code> 和 input
但有 60px
边距。显然保证金崩溃不起作用。如何修复input
的CSS规则,同时保持input
在顶部产生30px
垂直边距的能力?
Consider following code:
<p style="margin: 30px 0; padding: 0;">Some text some text some text some text some
text some text some text some text</p>
<p style="margin: 30px 0; padding: 0;">Some text some text some text some text some
text some text some text some text</p>
<input type="button" value="Button" style="margin: 30px 0; padding: 0; float: right;"/>
30px
margin expected between last p
and input
but there is 60px
margin. Apparently margin collapsing not working. How to fix CSS rules of input
while keeping the ability of input
to produce 30px
vertical margin on top?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试在
input
上设置display:block
编辑:然后在它周围扔一个包装器?
http://jsfiddle.net/8mqHZ/13/
Try setting
display:block
on theinput
EDIT: Just throw a wrapper around it then?
http://jsfiddle.net/8mqHZ/13/
我找到的唯一解决方案:
一点点破解。
The only solution I have found:
A little bit of hack.