从零开始前端学习[22]:cursor鼠标悬浮效果和opacity透明度效果

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的颜色变透明了

欢迎访问博客

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值