日期:2014-05-17  浏览次数:20678 次

超链接中样式表的使用问题
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!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=gb2312" />
<title>无标题文档</title>
<style type="text/css">
body{ font-size:small;
family:"Times New Roman","宋体";
}
h1{ font-size:140%;
}
a{ padding-left:40px;
  padding-top:10px;
  padding-bottom:10px;
  height:40px;
  font-size:small;
  line-height:3em;
  background-position:left;
  background-repeat:no-repeat;
   
   
}
a[id="1"]{ background-image:url(user.gif);
  background-color:yellow;
}
</style>
</head>

<body>
<h1>请选择适当类型</h1>
<a href="time.jsp"id="1">下载</a>(Word文档格式)</br>
<a href="#" type="pdf">下载</a>(PDF文档格式)</br>
<a href="#" type="xls" >下载</a>(Excel文档格式)</br>
</body>
</html>

上面的代码中给超链接加上样式表,在<a></a>之间的是超链接的内容,为什么a中的属性background-image:url(user.gif)也成了超链接的一部分?是因为它和“下载”都放在内联元素中所致?还有给超
接加样式表这种形式中a[]{ }中括号放设置的属性,起限定的作用,这是一种固定格式??

------解决方案--------------------
不知道我有没有猜对你的意思

HTML code

a {
    background-position: left center;
    background-repeat: no-repeat;
    font-size: small;
    height: 40px;
    line-height: 3em;
    [color=#FF0000]margin-bottom: 10px;
    margin-left: 40px;
    margin-top: 10px;[/color]
   }