[英]CSS color property not changing text color?
就像它說的那樣,color屬性不會改變文本的顏色。
HTML:
<body>
<header>
<ul id="navbar">
<li><a href="/home.html">Home</a></li>
<li><a href="/money.html">Money</a></li>
<li><a href="/sports.html">Sports</a></li>
</ul>
</header>
</body>
和CSS:
#navbar {
list-style-type: none;
}
#navbar li {
background-image: url(../images/bg-nav.c.gif);
background-position: left top;
color: white;
float: left;
font-family: "Gill Sans", "Gill Sans MT", "Myriad Pro", "DejaVu Sans Condensed", Helvetica, Arial, sans-serif;
height: 37px;
text-align: center;
text-decoration: none;
width: 120px;
}
您已將顏色應用於<a>
標簽。 找到以下變化
#navbar li a{
color:#fff;
}
您需要定位li
內的anchor( a
)元素。
嘗試#navbar li a
你必須改變
a:link { }
a:visited { }
a:hover { }
a:active { }
如果您在網站上使用多個鏈接,則可能與您的導航欄相關。
#navbar {
font-family: "Gill Sans", "Gill Sans MT", "Myriad Pro", "DejaVu Sans Condensed", Helvetica, Arial, sans-serif;
}
#navbar li {
float: left;
list-style-type: none; /*apply list-style to li*/
text-align: center;/*here we are telling LI to `text-center` all child anchor */
}
#navbar a {
background-image: url(https://d3ui957tjb5bqd.cloudfront.net/uploads/2013/05/firelight-logo-preview-1-f-560x372.png);
background-position: left top;
background-size:100% auto;
background-repeat:no-repeat;
color: white;
text-decoration: none;
padding: 20px 60px; /* use padding instead of width and height since you don't know how long the text will be */
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.