我想要我的< 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>
这个:
a:hover {text-decoration: underline;} <a style=" text-decoration:none; color:red" href="">Site Map</a>
也不起作用.
我该怎么办?问题是什么?
提前致谢.
解决方法
style属性比任何选择器都多
specific,所以它总是会在级联中最后应用(可怕的!重要规则不能承受).将CSS移动到样式表.
a.hover { color: red; text-decoration: none; } a.hover:hover { text-decoration: underline; }
(我还建议为该类提供更多的语义名称).
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。