html - 如何改变<hr>标签的粗细和颜色?

标签 html css colors thickness

<分区>

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

我做错了什么?

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

最佳答案

不确定您认为几乎不可见的是什么,但 5 像素的高度非常明显。 :)

确保您在其他可能覆盖此规则的 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">

关于html - 如何改变<hr>标签的粗细和颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34932679/

相关文章:

html - 为什么 WebSocket 可以和 HTTP "after the handshake"共享 80 端口?

html - 如何将页脚粘贴到屏幕底部并防止中间部分延伸到页脚下方?

html - 在没有全屏浏览器的情况下显示图像的全高(使用封面)

javascript - 如何在 CSS 模块中使用全局父选择器

python - 如何使用 Matplotlib 获得 N 种易于区分的颜色

javascript - 分区和动画

javascript - 未捕获的类型错误 : Cannot read property 'latitude' of undefined

html - 如何使子div比父div宽

c - 连续迭代 RGB?

html - html 中的 StackExchange 颜色图标