制作链接类

时间:2013-01-29 02:12:06

标签: css class hyperlink

我创建了一个我想用样式链接制作的网站。我不想为所有链接设置通用样式。我想为他们制作不同的课程。

我试过在测试页面上做这个,我无法让它工作。 这是代码:

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<style type="text/css">
test: link {
    font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
    font-size: 1em;
    color: #C00;
}
test: hover {
    font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
    font-size: 1em;
    color: #6F0;
}
test: active {
    font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
    font-size: 1em;
    color: #90F;
}
test: visited {
    font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
    font-size: 1em;
    color: #FF0;
}
.test {
    font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
    font-size: 1em;
    line-height: 1em;
    color: #999;
}
</style>
</head>

<body>
Emily

<p>sdlkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjlsdkf
sdlkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjlsdkf
sdlkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjlsdkf
sdlkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjlsdkf

  <span class="test"><a href="http://www.ehow.com/how_2080242_style-link-css.html">rose</a> 

  <a href="http://www.ehow.com/how_2080242_style-link-css.html"> daisy</a> 

  <a href="http://www.ehow.com/how_2080242_style-link-css.html">tulip</a> 

  <a href="http://www.ehow.com/how_2080242_style-link-css.html"> cactus</a> </span>
<p>ldkfjsldkfjlsdkfsdlkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjs    ldkfjsldkfjlsdkfsdlkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsldkfjsld



</body>
</html>

有人能告诉我我做错了什么。谢谢!

1 个答案:

答案 0 :(得分:3)

这里几乎没有错。测试是一个类,这意味着它需要一个句点 - .test。其次,链接在测试范围内。因此,您应该.test a指示测试范围中的链接。最后,您需要在分号前放置链接标记a。没有空间。

http://jsfiddle.net/vPBCB/

.test a:link {
    font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
    font-size: 1em;
    color: #C00;
}