我想在文本上方和下方添加空格。
我尝试添加
margin-top
但它被另一个元素覆盖了。如何使用 CSS 做到这一点?
如果有人有任何建议,我将不胜感激。谢谢!
我的div代码是:
<div id="idTestXxx" style="float:left; margin-left:120px; color:red; font-weight: bold; display: block; width: 400px; margin-top:5px;">※Test display description</div>
使用 CSS padding 属性而不是 margin。填充会在元素内部添加空间,而边距会在元素外部添加空间。
<div id="idTestXxx" style="float:left; margin-left:120px; color:red; font-weight: bold; display: block; width: 400px; padding-top: 20px; padding-bottom: 20px;">※Test display description</div>