透明遮罩层鼠标滑过效果-2(div+css)

1.代码:


<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>遮罩层划过效果title>
head>
<style type="text/css">
    body,p,dl,dd,ul,ol,li,div,h1,h2,h3,h4,h5,h6,form,input,table,tr,td{
        padding: 0;
        margin: 0;
    }
    .box{
        width:200px;
        height:150px;
        margin:30px;
        position: relative;
        top:0;
        left:0; 
        overflow:hidden;
    }
    .imgclass{
        display: block;
    }
    .bdDiv{
        width:200px;
        height:150px;
        background: gray;
        position: absolute;
        top:150px;
        left:0;
        opacity: 0.5;/*透明度设置(0-1),低版本浏览器不支持此属性*/
        filter:alpha(opacity=50);/*此时取值为0到100*/
        transition: all .6s; 
    }
    .word{
        width:200px;
        height: 40px;
        background: #00b7ee;
        color:white;
        font-size: 16px;
        line-height: 40px;
        text-indent: 30px;
        text-decoration: none;/*去掉下划线*/
        position: absolute;
        bottom:-40px;
        left:0;
        transition: all .6s; 
    }
     .box:hover .bdDiv{
        top:0px;
    }
    .box:hover .word{
        bottom:0px;
    } 
style>
<body>
    <div class="box">
        <img class="imgclass" src="img/1.jpg"/>
        <div class="bdDiv">div>
        <a class="word" href="#">这本书真尼玛好看!a>
    div>
body>
html>

2.结果展示:

透明遮罩层鼠标滑过效果-2(div+css)_第1张图片

3.备注:

利用transition属性实现渐变动画效果。

你可能感兴趣的:(CSS3)