将padding-top应用于具有border-radius的样式,以打破border-radius功能

时间:2013-11-19 17:15:44

标签: html html5 css3

<img src="Image source here" width="132" height="148" style="border-radius:3px;padding-top:50px"/>

任何人都可以清楚地说明为什么添加padding-top,这似乎会导致浏览器忽略border-radius属性?

您可以通过从样式属性中删除/添加填充来进行快速测试,注意 WITH 填充的方式,忽略border-radius。

这是一个错误,还是有充分的理由支持这个?

感谢您的时间。

3 个答案:

答案 0 :(得分:2)

是因为通过添加填充顶部边框只需向上(50px),因此请使用margin-top。 像这样(我添加背景颜色以更好地看待它)

<img src="Image source here" width="132" height="148" style=" background-color: #3d3d3d; border-radius:3px; margin-top:50px; "/>

我希望它有所帮助

在这里查看codepen

答案 1 :(得分:1)

看看盒子模型配偶,你应该在这里使用margin-top。

答案 2 :(得分:1)

<img src="https://www.google.com/images/srpr/logo11w.png" width="132" height="148" style="border: 3px solid red; padding-top: 50px;"/>

<强>更新 * 小提琴: * http://jsfiddle.net/Shashi0812/GJ8Bt/

相关问题