开发者

How to make margin collapsing work with input type=button/submit?

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;"/&开发者_开发技巧gt;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​

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?


Try setting display:block on the input

EDIT: Just throw a wrapper around it then?

http://jsfiddle.net/8mqHZ/13/


The only solution I have found:

<div style="text-align: right; margin: 30px 0;">
    <input type="button" value="Button" />
</div>​​​​​​​​​​

A little bit of hack.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜