您的位置:主页>>老有所学>去掉超链接的下划线
        去 掉 超 链 接 的 下 划 线
  在网页的制作中,无论是首页还是目录页,有些文字都需要进行超链接。在默认的情况下,已经链接过的文字,下边都有一条下划线。看上去页面有些乱,很不美观。如何去掉这条下划线,在年轻人和专业人员来说,只不过是手到勤来的事情,对老年人就有些困难。现介绍一个简单的方法,供网友参考。
  在源代码的<head>和<head>之间加上如下的CSS语法控制:
  
     <style type="text/css">
     <!--
     a:link { text-decoration: none;color: blue}
     a:active { text-decoration:blink}
     a:hover { text-decoration:underline;color: red}
     a:visited { text-decoration: none;color: green}
     -->
     </style>

  
    代码分析:
    a:link 指正常的未被访问过的链接,blue 文字为兰色。
    a:active 指正在点的链接。
    a:hover 指鼠标在链接上,red 文字为红色。
    a:visited 指已经访问过的链接,black 文字为黑色。
    text-decoration 是文字修饰效果的意思。
    none 参数表示超链接文字不显示下划线。
    underline 参数表示超链接的文字有下划线。

  现将实例介绍如下:下边的源代码是“夕阳晚情”网站,首页刊头部分,将CSS语法控制加入的位置。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>欢迎光临 夕阳晚情</title><style type="text/css">
     <!--
     a:link { text-decoration: none;color: blue}
     a:active { text-decoration:blink}
     a:hover { text-decoration:underline;color: red}
     a:visited { text-decoration: none;color: black}
     -->
     </style>

<body bgcolor="#E6FFFF">
<table width="100%" border="1" bordercolor="#CCCCCC" bgcolor="#FFFFD7">
<tr>
<td width="20%" align="center"><img src="img/kantou-1.jpg" width="140" height="80"></td>
<td width="67%" align="center"><img src="img/i-1/biaoti-01.jpg" width="483" height="80"></td>
<td width="13%" align="center" valign="middle"><STYLE>A.menuitem {
COLOR: menutext; TEXT-DECORATION: none
}
A.menuitem:hover {
COLOR: highlighttext; BACKGROUND-COLOR: highlight
}
DIV.contextmenu {
BORDER-RIGHT: 2px outset; BORDER-TOP: 2px outset; Z-INDEX: 999; VISIBILITY: hidden; BORDER-LEFT: 2px outset; BORDER-BOTTOM: 2px outset; POSITION: absolute; BACKGROUND-COLOR: buttonface
}
  以上源代码只是刊头的一小部分,以下从略。凡是初学作网页的朋友,不妨一试。

 
返 回 首 页  返 回 目 录