低效率的
CSS代码
- body { font-size: 85%; font-family: arial, helvetica, sans-serif;
- background-image: url(image.gif); background-repeat: no-repeat;
- background-position: 0 100%; margin-top: 1em; margin-right: 1em;
- margin-bottom: 0; margin-left: 1em; padding-top: 10px;
- padding-right: 10px; padding-bottom: 10px; padding-left: 10px;
- border-style: solid; border-width: 1px;
- border-color: red; color: #222222;
高效的
CSS代码
- body { font: 85% arial, helvetica, sans-serif;
- background: url(image.gif) no-repeat 0 100%;
- margin: 1em 1em 0; padding: 10px;
- border: 1px solid red; color: #222; }
七、避免使用 !important
慎用写法
CSS代码
- #news { background: #ddd !important; }
特定情况下可以使用以下方式提高权重级别
CSS代码
- #container #news { background: #ddd; }
- body #container #news { background: #ddd; }