jal*_*ami 9 html css tags html5 css3
我希望我的<a>标记在悬停时变为下划线,并且我使用了此代码,但在悬停时它没有下划线.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
a.hover:hover {text-decoration: underline;}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<a class="hover" style=" text-decoration:none; color:red" href="">Site Map</a>
</div>
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这个:
a:hover {text-decoration: underline;}
<a style=" text-decoration:none; color:red" href="">Site Map</a>
Run Code Online (Sandbox Code Playgroud)
也不起作用.
我该怎么办?问题是什么?
提前致谢.
Que*_*tin 27
该style属性比任何选择器更具体,因此它总是在级联中最后应用(可怕的!important规则不能承受).将CSS移动到样式表.
a.hover {
color: red;
text-decoration: none;
}
a.hover:hover {
text-decoration: underline;
}
Run Code Online (Sandbox Code Playgroud)
(我还建议为该类提供更多的语义名称).