【发布时间】:2011-01-26 10:54:58
【问题描述】:
以下三段代码的行为完全相同:
<p {padding: 0 15 0 15}> A paragraph of text here... </p>
<p> A paragraph of text here... </p>
<p style="padding: 0 15 0 15"> A paragraph of text here... </p>
如何让段落两边缩进? (我尝试了 15px 而不是 15(编辑 - 但仅在前两个上),我还尝试用逗号分隔数字,就像我在 Google 上找到的示例一样。)
以上代码是在body中的一个div中,不涉及其他div或table等。
div 已定义:
<div style="background-color: white; color: black; overflow:auto">
感谢您的帮助。
【问题讨论】:
-
建议使用 15px 而不是 15,以使解决方案(使用“样式”)适用于所有浏览器。我见过某些 IE 版本忽略没有单位的值。 w3.org/TR/REC-CSS1/#units - 只有当值为“0”时,您才会保存以省略单位。
-
除了下面的好答案,我可以建议 firefox 和 firebug 插件在解决您的 html 样式问题时非常有用。