Html CSS更改hr标签的颜色

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9773320/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 23:14:43  来源:igfitidea点击:

CSS change color of hr tag

htmlcss

提问by user1269625

Possible Duplicate:
CSS : change color of hr tag

可能的重复项:
CSS:更改 hr 标签的颜色

how do you change the color of an hr tag? i looked it up and found this, but it didnt work..

你如何改变hr标签的颜色?我查了一下,发现了这个,但是没有用。。

hr{
    color:#CCC;
    background-color:#CCC;
}

Any ideas?

有任何想法吗?

回答by Paul Sham

Style the border.

设置边框样式。

hr{
   border: 1px solid #ccc;
}

回答by dangerChihuahua007

Just change the border color. For instance, this HTML produces a red horizontal row.

只需更改边框颜色。例如,此 HTML 生成一个红色的水平行。

<hr style="border: 1px solid #f00" />?

回答by Duncan Gravill

try changing the color of it's border

尝试更改其边框的颜色

回答by Fabrizio Calderan

probably the best way to add a custom style to show an horizontal rule in a crossbrowserway is to style instead a border-top of the following element (or the border-bottom of previous one)

添加自定义样式以跨浏览器方式显示水平线的最佳方法可能是设置样式而不是以下元素的边框顶部(或前一个元素的边框底部)

Another solution is to style :after or :before psuedoelements of one of the <hr>adjacent/sibling elements

另一种解决方案是将 :after 或 :before 样式设置为<hr>相邻/兄弟元素之一的伪元素

回答by Fabrizio Calderan

Try using this:

尝试使用这个:

<hr noshade="noshade" />

as your hr tag, and then use the same CSS as you have already.

作为您的 hr 标签,然后使用与您相同的 CSS。

EDIT:

编辑:

You can also add

您还可以添加

border: 1px solid #CCC;

to your CSS.

到您的 CSS。