1 html css text colors hyperlink
我无法让我的链接保持白色.
这是头部代码.
float1 {
position: absolute;
width: 250px;
height: 40px;
z-index: 1;
left: 40px;
top: 300px;
font-size: 35px;
background-color: black;
color: white;
text-align: center;
color: white;
text-decoration: none;
}Run Code Online (Sandbox Code Playgroud)
<div id="float1">
<font color="white"><a href="#" onclick="myfun();">Home</a></font>
</div>Run Code Online (Sandbox Code Playgroud)
默认情况下,Anchor标签具有自己的属性(如果href存在)(向用户显示它是链接)
您需要将颜色直接添加到a标记:
#float1 a{
color: #FFF;
}
Run Code Online (Sandbox Code Playgroud)
a如果您愿意,可以选择所有标签:
a{
color: #FFF;
}
Run Code Online (Sandbox Code Playgroud)
您可以使用color: inherit上a,然后将继承其父是:
#float1 a{
color: inherit;
}
Run Code Online (Sandbox Code Playgroud)
并删除<font></font>HTML5中不支持的标记