下划线< a>悬停时标记 [英] underline <a> tag when hovering

查看:103
本文介绍了下划线< a>悬停时标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望我的< a> 标签在悬停时获得下划线,并且我使用了此代码,但悬停时没有下划线。

I want my <a> tag gets underline when hovering,and I am used this code,but it doesn't have underline when hovering.

<%@ 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>

这:

this:

a:hover {text-decoration: underline;}
<a  style=" text-decoration:none; color:red" href="">Site Map</a>

也不起作用。

我应该怎么办?是什么问题?

what should I do?what is the problem?

预先致谢。

推荐答案

style 属性更多 specific ,因此它总是会在层叠中最后应用(可怕的!important !规则不被承受)。

The style attribute is more specific than any selector, so it will always be applied last in the cascade (horrible !important rules not withstanding). Move the CSS to the stylesheet.

a.hover {
    color: red;
    text-decoration: none;
}

a.hover:hover {
    text-decoration: underline;
}

(我也建议这个类的语义名称更多)。

(I also suggest a more semantic name for the class).

这篇关于下划线&lt; a&gt;悬停时标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆