这段CSS代码为什么不起作用?

Tenner 2005-04-27 05:30:48
Styles.css 文件内容:

A.titlebar
{
font: caption;
color: White;
background-color: DarkBlue;
}
.titlebar
{
font: caption;
color: White;
background-color: darkblue;
}

index.htm 文件内容:
<HTML>
<HEAD>
<title>Login</title>
<link rel="stylesheet" type="text/css" href="./Styles.css">
</HEAD>
<body>
<p align="center">
<table id="tblTitle" class="titlebar">
<tr><td><a href=./login.aspx>Login</a></td></tr>
</table>
</p>
</body>
</HTML>

但页面显示出来以后,里面那个"Login"的键接的颜色还是默认的,并没有改变
这是为什么,我只想让这个表格里的所有链接都按一种样式显示,应该怎么做?
...全文
112 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
ddcatlee 2005-04-28
  • 打赏
  • 举报
回复
你要这样定义:

.titlebar{......}
.titlebar a:visited{......}

这个表示,对.titlebar里面的a定义。

你定义的 a.titlebar{} 只有在你<a class="titlebar" href="...">时才起作用。
这个是对a定义的。
Tenner 2005-04-28
  • 打赏
  • 举报
回复
楼上的,十分感谢,给分!
Tenner 2005-04-27
  • 打赏
  • 举报
回复
还是不行,我用的是 link 引入的外部CSS文件,在文件里直接定义A有用,加上.类名就不行了
全文如下:
.titlebar
{
font: caption;
color: White;
background-color: darkblue;
text-decoration: none;
}
A.titlebar:link
{
font: caption;
color: White;
background-color: DarkBlue;
}
A.titlebar:activate
{
font: caption;
color: White;
background-color: DarkBlue;
}
A.titlebar:hover
{
font: caption;
color: White;
background-color: DarkBlue;
}
A.titlebar:visited
{
font: caption;
color: White;
background-color: DarkBlue;
}
.normal
{
font-size: 12pt;
color: midnightblue;
font-family: Arial;
background-color: aliceblue;
}
.headerbar
{
font-family: Arial;
font-size: 12pt;
color: white;
background-color: dimgray;
}
高手帮我看看是怎么回事啊
fengzi0924 2005-04-27
  • 打赏
  • 举报
回复
样式定义错了


<!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">
<!--
.titlebar{
color: White;
background-color: darkblue;
font-family: "caption";
text-decoration: none;
}
A.titlebar:hover{
font: caption;
color: White;
background-color: DarkBlue;
}

-->
</style>
</head>

<body>
<table width="50" height="50" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center" class="unnamed1"><a href="#" class="titlebar">logt</a></td>
</tr>
</table>
</body>
</html>
myvicy 2005-04-27
  • 打赏
  • 举报
回复
应该是你浏览器出问题了。
我这里也出过这样的问题。
Tenner 2005-04-27
  • 打赏
  • 举报
回复
难道是浏览器问题?
我这里看还是没变.....
leo963258 2005-04-27
  • 打赏
  • 举报
回复
我这里改变了.
<HTML>
<HEAD>
<title>Login</title>
<style>
A.titlebar
{
font: caption;
color: White;
background-color: DarkBlue;
}
.titlebar
{
font: caption;
color: White;
background-color: darkblue;
}
</style>
</HEAD>
<body>
<p align="center">
<table id="tblTitle" class="titlebar">
<tr><td><a href=./login.aspx>Login</a></td></tr>
</table>
</p>
</body>
</HTML>

61,112

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧