HTML超連結a標記CSS樣式寫法樣本

來源:互聯網
上載者:User

定義連結樣式的四個偽類

    1 :link   
    
    2 :visited   
    
    3 :hover   
    
    4 :active  

因為我們要定義連結樣式,所以其中必不可少的就是超級連結中的錨標籤--a,錨標籤和偽類連結起來書寫的方法就是定義連結樣式的基礎方法,它們的寫法如下:


    1 a:link,定義正常連結的樣式;   
    
    2 a:visited,定義已訪問過連結的樣式;   
    
    3 a:hover,定義滑鼠懸浮在連結上時的樣式;   
    
    4 a:active,定義滑鼠點選連結時的樣式

樣式表CSS中定義連結 A 的順序,可能會對大家有一些協助:


A:link { color: #000000; TEXT-DECORATION: none}
A:visited { COLOR: #000000; TEXT-DECORATION: none}
A:hover { COLOR: #ff7f24; text-decoration: underline;}
A:active { COLOR: #ff7f24;   text-decoration: underline;}


a :link、a:hover、a:visited這幾個元素,定義CSS時候的順序不同,也會直接導致連結顯示的效果不同。
我想,原因就在於瀏覽器解釋CSS時遵循的“就近原則”。

 代碼如下 複製代碼


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
<!--
A.mytest:link {
 FONT-SIZE: 12px; COLOR: #5b5b5b; TEXT-DECORATION: none
}
A.mytest:visited {
 FONT-SIZE: 12px; COLOR: #969696; TEXT-DECORATION: none
}
A.mytest:active {
 FONT-SIZE: 12px; COLOR: #0099ff; TEXT-DECORATION: none
}
A.mytest:hover {
 FONT-SIZE: 12px; COLOR: #ff6102; TEXT-DECORATION: none
}
--></style>
<title>Insert title here</title>
</head>
<body>
<A href="#" class="mytest">test</A>
</body>
</html>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.