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

CSS样式的一点小疑惑
在定义css样式表的时候有时后定义成.ButtonCss有时候定义成td.f,这种前面带个点.和不带.的有什么区别吗?

------解决方案--------------------
带点的是用 class= "点后面的名称 " 引用的
如:
.test{border:2px solid #ff0000;}
<div class= "test "> test </div>

不带点的则是直接定义html标记

td{border:3px solid #00ff00;}
那么以下所以的有 <td> ssss </td> 中的内容都按照上面的定义
------解决方案--------------------
给个例子给你
<!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 ">
.test{border:1px solid #ff0000;}
input{border:1px solid #0000ff;}
</style>
</head>
<body>
<div class= "test "> 带class的 </div>
<div> 没带class的 </div>
<input type= "text " />
<input type= "button " />
</body>
</html>
------解决方案--------------------
td.class 表示该类是专门定义给td标签的,其他同时定义了class但标签不为td的不起作用.
.class是通用的类定义,只要定义了class的所有标签都将应用该类.
.class 和 tag.class有点类似于包含关系,但子集优先级更高,同时碰到时,优先显示tag.class

eg:
<style>
.a {width: 100px; height: 50px; background-color: red;}
span.a{width: 100px; height: 50px; background-color: blue;display:block}
</style>
<div class=a> </div>
<div class=a> </div>
<span class=a> a </div>
------解决方案--------------------
.Defined{}
td{} //HTML TAG

------解决方案--------------------
问题解决了结贴啊