简体   繁体   English

为什么我的文本不更改为我输入的颜色代码? (它保持蓝色)

[英]Why isn't my text changing to the color code I put in? (It stays blue)

This is the code, as you can see I'm trying to change the color to a grey, but every time I preview the changes and/or save it stays blue. 正如您所看到的,这是代码,我正在尝试将颜色更改为灰色,但是每次我预览更改和/或保存更改时,它都保持蓝色。

#title {
position:fixed;
font-size:40px;
font-family: 'Jim Nightshade', cursive;
text-align:center;
padding-bottom:1px;
bottom:90px;
margin-left:0px;
width:500px;
height:-10px;
padding:5px;
overflow:hidden;
color:#a4a4a4;
line-height:100%;;
z-index:999999999;
transition-duration: 0.8s;
-moz-transition-duration: 0.8s;  
-webkit-transition-duration: 0.8s;
-o-transition-duration: 0.8s;

尝试将包装器更改为#title a {} ,因为我假设您正在谈论超链接。

Could be because of specificity, try adding !important to your color property. 可能是由于特殊性,请尝试在颜色属性中添加!important。

#title {
position:fixed;
font-size:40px;
font-family: 'Jim Nightshade', cursive;
text-align:center;
padding-bottom:1px;
bottom:90px;
margin-left:0px;
width:500px;
height:-10px;
padding:5px;
overflow:hidden;
color:#a4a4a4 !important;
line-height:100%;;
z-index:999999999;
transition-duration: 0.8s;
-moz-transition-duration: 0.8s;  
-webkit-transition-duration: 0.8s;
-o-transition-duration: 0.8s;
}

Probably you are using anchor within "title" element, that's why your browser is rendering default anchor color ie blue. 可能是您在“ title”元素中使用了锚点,这就是为什么您的浏览器呈现默认锚点颜色(即蓝色)的原因。

Suppose you are having an html like 假设您有一个类似HTML

<div id="title">
 <a href="#">Test Color</a>
</div> 

If you apply CSS to "title" div as 如果您将CSS应用于“ title” div,

#title {
position:fixed;
font-size:40px;
font-family: 'Jim Nightshade', cursive;
text-align:center;
padding-bottom:1px;
bottom:90px;
margin-left:0px;
width:500px;
height:-10px;
padding:5px;
overflow:hidden;
color:#a4a4a4;
line-height:100%;;
z-index:999999999;
transition-duration: 0.8s;
-moz-transition-duration: 0.8s;  
-webkit-transition-duration: 0.8s;
-o-transition-duration: 0.8s;
}

It will give blue color for text "Test Color" 它将为文本“ Test Color”赋予蓝色

Refer to fiddle for such effect 有关这种效果,请参阅小提琴

But if you apply CSS to "a" within "title" as 但是,如果您将CSS应用于“标题”中的“ a”

#title a{
text-decoration:none;
position:fixed;
font-size:40px;
font-family: 'Jim Nightshade', cursive;
text-align:center;
padding-bottom:1px;
bottom:90px;
margin-left:0px;
width:500px;
height:-10px;
padding:5px;
overflow:hidden;
color:#a4a4a4;
line-height:100%;;
z-index:999999999;
transition-duration: 0.8s;
-moz-transition-duration: 0.8s;  
-webkit-transition-duration: 0.8s;
-o-transition-duration: 0.8s;
}

It will show grey color for anchor too. 锚也会显示为灰色。

The updated code in fiddle 小提琴中更新的代码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM