cursor鼠标悬浮效果和opacity透明度效果
- cursor鼠标悬浮效果
- opacity透明度的效果
提示:
博主:章飞_906285288
博客地址:http://blog.csdn.net/qq_29924041
cursor鼠标悬浮效果
我们知道a标签是有一个默认鼠标悬浮上去就有一个小手指这样的一个效果,但是,如果不是a标签的时候呢?怎么在其他标签元素上面同样去添加这样的一个鼠标悬浮的效果呢??
这个时候就需要用到cursor属性了
cursor的使用:
cursor:pointer;//显示小手指的形式
常用cursor的属性值
cursor属性值 | 属性值的含义 |
---|---|
pointer | 小手指的效果 |
help | 帮助的效果 |
move | 可移动的效果 |
text | 文本选中的效果 |
wait | 等待的效果 |
代码比较:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<meta charset="UTF-8"><!--申明当前网页的编码集UTF-8-->
<meta name="Generator" content="EditPlus®"> <!--编辑器的名称-->
<meta name="Author" content="作者是谁">
<meta name="Keywords" content="关键词">
<meta name="Description" content="描述和简介">
<style type="text/css">
body,dl,dd,dt,p,h1,h2,h3,h4,h5,h6{ margin: 0;}
ul,ol{margin: 0; list-style: none; padding: 0;}
a{ text-decoration: none; }
*{ margin: 0; padding: 0; }
.f_l{float: left}
.f_r{float: right}
.clearfix:after{
content: "";
clear: both;
display: block;
}
.main{width: 1200px;margin: 50px auto;box-shadow: 0 0 10px 0 deeppink}
.main div{width: 200px;height: 200px;background: blue;line-height: 200px;text-align: center;margin-left: 10px}
.main .box1{cursor: pointer}
.main .box2{cursor: wait}
.main .box3{cursor: move}
.main .box4{cursor: text}
.main .box5{cursor: help}
</style>
</head>
<body>
<div class="main clearfix">
<div class="box1 f_l">pointer</div>
<div class="box2 f_l">wait</div>
<div class="box3 f_l">move</div>
<div class="box4 f_l">text</div>
<div class="box5 f_l">help</div>
</div>
</body>
</html>
显示效果如下:
opacity透明度的效果
之前我们提过使用rgba来作为背景图片的透明度转换,但是在css中,有一个专门的属性,叫opacity属性来作为透明度效果的展示问题
在新版本兼容上可以直接使用opacity:0.5;来表示透明度50%
但是在老版本的浏览器上,并不是兼容,所以为了保持兼容性问题,
需要使用filter:alpha(opacity:50) //取值范围为0-100;
对上述的案例box5进行修改一下
.main .box5{cursor: help;opacity: 0.5;filter:alpha(opacity: 50); }
可以看到的是:
box5的颜色变透明了