HTML – 如何更改元素的颜色?

HTML – 如何更改元素的颜色?,第1张

概述我尝试了各种方法来改变< hr />的颜色: hr{ border-color: yellow; background-color: yellow; color: yellow; } 但它在Chrome和FF中都显示如下: 如何将其颜色更改为纯黄色? 给hr一个风格: hr{ border:0; margin:0; width:100%; h 我尝试了各种方法来改变< hr />的颜色:

hr{   border-color: yellow;   background-color:  yellow;   color: yellow;  }

但它在Chrome和FF中都显示如下:

如何将其颜色更改为纯黄色?

解决方法 给hr一个风格:

hr{    border:0;    margin:0;    wIDth:100%;    height:2px;    background:yellow;}

要么

border:1px solID yellow;

JsFiddle

您需要摆脱边框或更改边框的属性才能正常工作.

从@Darko Z开始评论:

In many browsers the default style for HR is to add some sort of shading to the border so this comes out as dirty #whateverColourYouWant. To get rID of it,setting border explicitly (and not just border-color) is necessary.

总结

以上是内存溢出为你收集整理的HTML – 如何更改元素的颜色?全部内容,希望文章能够帮你解决HTML – 如何更改元素的颜色?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1043506.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-24
下一篇2022-05-24

发表评论

登录后才能评论

评论列表(0条)

    保存