css的hover兼容问题

html-css012

css的hover兼容问题,第1张

CSS中的超链接 hover伪类是所有浏览器都支持的,也都是兼容的.但其他标签的伪类不是全部浏览器都支持,IE6就是不支持的,例如tr:hover,在IE6浏览器不支持这种效果。

有疑问可以追问我哦。

CSS伪类(Pseudoclasses)是选择符的螺栓,用来指定一个或者与其相关的选择符的状态。它们的形式是selector:pseudoclass{property:value},简单地用一个半角英文冒号(:)来隔开选择符和伪类。

CSS很多的建议并没有得到浏览器的支持,但有四个可以安全使用的用在连接上的CSS伪类。

◆link用在为访问的连接上。

◆visited用在已经访问过的连接上。

◆hover用于鼠标光标置于其上的连接。

◆active用于获得焦点(比如,被点击)的连接上。

a:link{color:red }  

a:visited{color:green}  

a:hover{color:blue}  

a:active{color:orange}

参考于

zhangbaoenji

的答案

伪类选择器,伪类和伪元素的区别, css3中伪类选择器和伪物件选择器的区别

伪类 按现在的规范应当书写成 :weilei伪元素 按现在的规范 应当书写成 ::weiyuansu

但是 以前规范不明确的时候 伪元素 和 伪类 都是写成 :weiyuansu :weilei

为了相容过去的写法

所以 你的伪元素 写成一个引号的形式 也是可以被解析的

伪元素主要有:E:first-letter/E::first-letter E:first-line/E::first-line E:before/E::before E:after/E::after E::placeholder E::selection

伪类主要有:E:link E:visited E:hover E:active E:focus E:lang(fr) E:not(s) E:root E:first-child E:last-child E:only-child E:nth-child(n) E:nth-last-child(n) E:first-of-type E:last-of-type E:only-of-type E:nth-of-type(n) E:nth-last-of-type(n) E:empty E:checked E:enabled E:disabled E:target @page:first @page:left @page:right

单冒号 双冒号 主要是为了区别 伪元素还是伪类

的伪类选择器

<style type=text/css>

/*

伪类选择器:伪类选择器就是对元素处于某种状态下进行样式的。

注意:

1. a:hover 必须被置于 a:link 和 a:visited 之后

2. a:active 必须被置于 a:hover 之后

*/

a:link{color:#F00} /* 没有被点选过---红色 */

a:visited{color:#0F0} /* 已经被访问过的样式---绿色 */

a:hover{color:#00F} /* 滑鼠经过的状态---蓝 */

a:active{color:#FF0}

</style>

应用 程式码:

<!DOCTYPE PUBLIC "-W3CDTD XHTML 1.0 TransitionalEN" ":w3./TR/x1/DTD/x1-transitional.dtd">

<xmlns=":w3./1999/x">

<head>

<meta -equiv="Content-Type" content="text/charset=utf-8" />

<title>无标题文件</title>

</head>

<style type=text/css >

table{

background-color:#CCC

border-collapse:collapse

border:3px

}

tr:hover{

background-color:#06F

}

</style>

<body>

<table border=1px width=400px height=300px align=center >

<tr>

<th>姓名</th>

<th>成绩</th>

<th>人品</th>

</tr>

<tr>

<td>张三</td>

<td>98</td>

<td>差</td>

</tr>

<tr>

<td>李四</td>

<td>50</td>

<td>极好</td>

</tr>

<tr>

<td>综合测评</td>

<td colspan="2">不错</td>

</tr>

</table>

</body>

</>

怎么用伪类选择器nth-frist-child

伪类选择器nth-frist-child,应该是伪类选择器 nth-child(),其在IE6-8和FF3.0-浏览器不支援,CSS3中nth-of-type(n)(比如nth-of-type(1))这个特殊的类选择符可以样式更加个性的标题和段落等,不过,目前nth-of-type(n)只支援火狐3、opera、safari和chrome等部分浏览器。

例子:

li:nth-child(3){background:orange}/*把第3个li的背景设为橙色*/

li:nth-child(3n){background:orange}/*把第3、第6、第9、…、所有3的倍数的li的背景设为橙色*/

li:nth-child(n+3){background:orange}/*选择从第3个元素后面的li背景设为橙色*/

li:nth-child(-n+3){background:orange}/*选择从第3个元素前面的li把背景设为橙色*/

li:nth-child(3n+1){background:orange}/*这种方法是实现隔几选一的效果*/

标记选择器、类选择器、id选择器、伪类选择器的先后顺序是什么?

1、id选择器;

2、类选择器;

3、标记选择器;

4、最后是伪选择器。

id选择器(#myid);

类选择器(.myclassname);

标签选择器(div,h1,p);

相邻选择器(h1+p);

子选择器(ul <li);

后代选择器(li a);

万用字元选择器(*);

属性选择器(a[rel="external"]);

伪类选择器(a:hover,li:nth-child)。