1

I tried changing the <hr> tag with CSS using:

hr { color:whitesmoke}

But it doesn't affect my HTML at all. Is there a way to change the horizontal line's color to a different color than the default one using CSS? For performance purposes, I don't want to use an img (horizontal line in the color I want with max-width: 100%) but some CSS rule.

4

3 回答 3

3

浏览器中的外观<hr>基于边框样式,而不是由color属性决定。因此,请尝试border-color改用:

hr {
  border: none;
  border-top: 1px solid whitesmoke;
}
<hr>

于 2017-08-14T18:39:32.853 回答
1

您可以使用:

hr { border: 0px; border-bottom: 1px solid whitesmoke; }
<hr/>

于 2017-08-14T18:39:03.430 回答
1

hr {border-top: 1px solid whitesmoke;}
<hr> 

于 2017-08-14T18:41:00.110 回答