如何改变厚度和<hr />标签的颜色?

时间:2016-01-21 19:30:54

标签: html css colors thickness

我可以看到这已经得到了解答,但我已经尝试了所有的解决方案,但仍然几乎看不到HR。

我做错了什么?

hr {
    background-color: dimgrey;
    color: dimgrey;
    border: solid 2px dimgrey;
    height: 5px;
    width: 1000px;
}

1 个答案:

答案 0 :(得分:10)

不确定您认为几乎看不到的东西但是5px的高度非常明显。 :)

确保您在其他可能覆盖此规则的CSS之后定义此css。

或者,使用!important来赋予此规则优先权:

hr {
    background-color: dimgrey !important;
    color: dimgrey !important;
    border: solid 2px dimgrey !important;
    height: 5px !important;
    width: 1000px !important;
}

另一种方法是为此样式定义自定义类:

.bigHr {
    background-color: dimgrey !important;
    color: dimgrey !important;
    border: solid 2px dimgrey !important;
    height: 5px !important;
    width: 1000px !important;
}

...然后在需要此样式时使用该类:

<hr class="bigHr">
相关问题