1. 程式人生 > >6種css3滑鼠滑過動畫效果

6種css3滑鼠滑過動畫效果

<html>

<head>
    <meta charset="utf-8" />
    <title>6種css3滑鼠滑過動畫效果</title>
    <style type="text/css">
    /*****全域性樣式*****/

    * {
        padding: 0;
        margin: 0;
        font-family: "微軟雅黑"
    }

    h2 {
        margin: 15px 0;
        font-weight: 300;
    }

    .content {
        margin: 0 auto;
        max-width: 728px;
        margin-top: 20px;
        text-align: center
    }

    footer {
        margin: 10px 0;
        font-size: 14px;
    }

    hr {
        margin: 20px 0;
    }

    code {
        font-size: 12px;
    }
    /*****滑鼠懸停圖片變大文字消失*****/

    .style1 ul li {
        float: left;
        margin: 0 6px;
        position: relative;
        list-style: none
    }

    .style1 ul li {
        -webkit-transition: all 0.5s;
        -moz-transition: all 0.5s;
        -o-transition: all 0.5s;
    }

    .style1 ul li img {
        width: 170px;
        height: 120px;
        border-radius: 2px;
    }

    .style1 ul li span {
        background: rgba(0, 0, 0, 0.5);
        color: #fff;
        border-bottom-left-radius: 2px;
        border-bottom-right-radius: 2px;
        line-height: 23px;
        position: absolute;
        bottom: 3px;
        width: 170px;
        left: 0;
        font-size: 12px;
        -webkit-transition: all 0.5s;
        -moz-transition: all 0.5s;
        -o-transition: all 0.5s;
        -ms-transition: all 0.5s;
    }

    .style1 ul li:hover {
        -webkit-transform: scale(1.1);
        /*1.1放大值*/
        -moz-transform: scale(1.1);
        -o-transform: scale(1.1);
        -ms-transform: scale(1.1);
        /*  本hover用的是:transform屬性;scale是屬性下放大;*/
    }

    .style1 ul li:hover span {
        opacity: 0
    }
    /*****滑鼠懸停文字消失*****/

    .style2 ul li {
        float: left;
        margin: 0 6px;
        position: relative;
        list-style: none
    }

    .style2 ul li img {
        width: 170px;
        height: 120px;
        border-radius: 2px;
        -webkit-transition: all 0.5s;
        -moz-transition: all 0.5s;
        -o-transition: all 0.5s;
    }

    .style2 ul li span {
        background: rgba(0, 0, 0, 0.5);
        color: #fff;
        border-bottom-left-radius: 2px;
        border-bottom-right-radius: 2px;
        line-height: 23px;
        position: absolute;
        bottom: 3px;
        width: 170px;
        left: 0;
        font-size: 12px;
        -webkit-transition: all 0.5s;
        -moz-transition: all 0.5s;
        -o-transition: all 0.5s;
        -ms-transition: all 0.5s;
        /*其意相同:transition:all;初始過度屬性 值0;*/
    }


    .style2 ul li:hover span {
        opacity: 0
    }
    /*opacit:0;代表完全消失;0.5半透明*/
    /*****滑鼠懸停整體旋轉*****/

    .style3 ul li {
        float: left;
        margin: 0 6px;
        position: relative;
        list-style: none
    }

    .style3 ul li {
        -webkit-transition: all 0.5s;
        -moz-transition: all 0.5s;
        -o-transition: all 0.5s;
    }

    .style3 ul li img {
        width: 170px;
        height: 120px;
        border-radius: 2px;
    }

    .style3 ul li span {
        background: rgba(0, 0, 0, 0.5);
        color: #fff;
        border-bottom-left-radius: 2px;
        border-bottom-right-radius: 2px;
        line-height: 23px;
        position: absolute;
        bottom: 3px;
        width: 170px;
        left: 0;
        font-size: 12px;
        transition: All 0.4s ease-in-out;
        -webkit-transition: All 0.4s ease-in-out;
        -moz-transition: All 0.4s ease-in-out;
        -o-transition: All 0.4s ease-in-out;
    }

    .style3 ul li:hover {
        transform: rotate(360deg);
        -webkit-transform: rotate(360deg);
        -moz-transform: rotate(360deg);
        -o-transform: rotate(360deg);
        /*css3旋轉屬性; 360deg(順時針旋轉360度)*/
        -ms-transform: rotate(360deg);
    }
    /*****滑鼠懸停整體旋轉放大*****/

    .style4 ul li {
        float: left;
        margin: 0 6px;
        position: relative;
        list-style: none
    }

    .style4 ul li {
        transition: All 0.4s ease-in-out;
        -webkit-transition: All 0.4s ease-in-out;
        -moz-transition: All 0.4s ease-in-out;
        -o-transition: All 0.4s ease-in-out;
    }

    .style4 ul li img {
        width: 170px;
        height: 120px;
        border-radius: 2px;
    }

    .style4 ul li span {
        background: rgba(0, 0, 0, 0.5);
        color: #fff;
        border-bottom-left-radius: 2px;
        border-bottom-right-radius: 2px;
        line-height: 23px;
        position: absolute;
        bottom: 3px;
        width: 170px;
        left: 0;
        font-size: 12px;
        transition: All 0.4s ease-in-out;
        -webkit-transition: All 0.4s ease-in-out;
        -moz-transition: All 0.4s ease-in-out;
        -o-transition: All 0.4s ease-in-out;
    }

    .style4 ul li:hover {
        transform: rotate(360deg) scale(1.2);
        -webkit-transform: rotate(360deg) scale(1.2);
        -moz-transform: rotate(360deg) scale(1.2);
        -o-transform: rotate(360deg) scale(1.2);
        /*transform 屬性下 rotate(旋轉)和scale(放大)屬性;可以同時用*/
        -ms-transform: rotate(360deg) scale(1.2);
    }
    /*****滑鼠懸停整體上升*****/

    .style5 ul li {
        float: left;
        margin: 0 6px;
        position: relative;
        list-style: none
    }

    .style5 ul li {
        transition: All 0.4s ease-in-out;
        -webkit-transition: All 0.4s ease-in-out;
        -moz-transition: All 0.4s ease-in-out;
        -o-transition: All 0.4s ease-in-out;
    }

    .style5 ul li img {
        width: 170px;
        height: 120px;
        border-radius: 2px;
    }

    .style5 ul li span {
        background: rgba(0, 0, 0, 0.5);
        color: #fff;
        border-bottom-left-radius: 2px;
        border-bottom-right-radius: 2px;
        line-height: 23px;
        position: absolute;
        bottom: 3px;
        width: 170px;
        left: 0;
        font-size: 12px;
        transition: All 0.4s ease-in-out;
        -webkit-transition: All 0.4s ease-in-out;
        -moz-transition: All 0.4s ease-in-out;
        -o-transition: All 0.4s ease-in-out;
    }

    .style5 ul li:hover {
        transform: translate(0, -10px);
        -webkit-transform: translate(0, -10px);
        -moz-transform: translate(0, -10px);
        -o-transform: translate(0, -10px);
        -ms-transform: translate(0, -10px);
    }
    /*****滑鼠懸停圖片放大縮小動畫*****/

    @-webkit-keyframes play {
        50% {
            transform: scale(0.8);
        }

        100% {
            transform: scale(1);
        }
    }

    .style6 ul li {
        float: left;
        margin: 0 6px;
        position: relative;
        list-style: none
    }

    .style6 ul li {
        transition: All 0.4s ease-in-out;
        -webkit-transition: All 0.4s ease-in-out;
        -moz-transition: All 0.4s ease-in-out;
        -o-transition: All 0.4s ease-in-out;
    }

    .style6 ul li img {
        width: 170px;
        height: 120px;
        border-radius: 2px;
    }

    .style6 ul li span {
        background: rgba(0, 0, 0, 0.5);
        color: #fff;
        border-bottom-left-radius: 2px;
        border-bottom-right-radius: 2px;
        line-height: 23px;
        position: absolute;
        bottom: 3px;
        width: 170px;
        left: 0;
        font-size: 12px;
        transition: All 0.4s ease-in-out;
        -webkit-transition: All 0.4s ease-in-out;
        -moz-transition: All 0.4s ease-in-out;
        -o-transition: All 0.4s ease-in-out;
    }

    .style6 ul li:first-child:hover {
        animation: play 0.3s 50 linear;
    }

    .style6 ul li:last-child:hover {
        animation: play 0.3s 50 linear;
        position: relative;
    }

    .style6 ul li:last-child h1 {
        position: absolute;
        color: red;
        top: 50px;
        font-size: 40px;
        left: 96px;
    }

    .style6 ul li:nth-child(2):hover {
        animation: play 0.3s 1 linear;
    }

    .style6 ul li:nth-child(3):hover {
        animation: play 0.3s 2 linear;
    }
    </style>
</head>

<body>

    <body class="content">
        <div class="style1 ">
            <h2>1.滑鼠懸停圖片變大文字消失</h2>
            <ul>
                <li><img src="http://img1.gtimg.com/autoxingtai/pics/hv1/25/31/204/13273030.jpg"><span>滑鼠懸停圖片變大文字消失</span></li>
                <li><img src="http://img1.gtimg.com/autoxingtai/pics/hv1/25/31/204/13273030.jpg"><span>滑鼠懸停圖片變大文字消失</span></li>
                <li><img src="http://img1.gtimg.com/autoxingtai/pics/hv1/25/31/204/13273030.jpg"><span>滑鼠懸停圖片變大文字消失</span></li>
                <li><img src="http://img1.gtimg.com/autoxingtai/pics/hv1/25/31/204/13273030.jpg"><span>滑鼠懸停圖片變大文字消失</span></li>
            </ul>
        </div>
        <div style="clear:both"></div>
        <div class="style2">
            <h2>2.滑鼠懸停文字消失</h2>
            <ul>
                <li><img src="http://img1.gtimg.com/autoxingtai/pics/hv1/25/31/204/13273030.jpg"><span>滑鼠懸停文字消失</span></li>
                <li><img src="http://img1.gtimg.com/autoxingtai/pics/hv1/25/31/204/13273030.jpg"><span>滑鼠懸停文字消失</span></li>
                <li><img src="http://img1.gtimg.com/autoxingtai/pics/hv1/25/31/204/13273030.jpg"><span>滑鼠懸停文字消失</span></li>
                <li><img src="http://img1.gtimg.com/autoxingtai/pics/hv1/25/31/204/13273030.jpg"><span>滑鼠懸停文字消失</span></li>
            </ul>
        </div>
        <div style="clear:both"></div>
        <div class="style3">
            <h2>3.滑鼠懸停整體旋轉</h2>
            <ul>
                <li><img src="http://img1.gtimg.com/autoxingtai/pics/hv1/25/31/204/13273030.jpg"><span>滑鼠懸停整體旋轉</span></li>
                <li><img src="http://img1.gtimg.com/autoxingtai/pics/hv1/25/31/204/13273030.jpg"><span>滑鼠懸停整體旋轉</span></li>
                <li><img src="http://img1.gtimg.com/autoxingtai/pics/hv1/25/31/204/13273030.jpg"><span>滑鼠懸停整體旋轉</span></li>
                <li><img src="http://img1.gtimg.com/autoxingtai/pics/hv1/25/31/204/13273030.jpg"><span>滑鼠懸停整體旋轉</span></li>
            </ul>
        </div>
        <div style="clear:both"></div>
        <div class="style4">
            <h2>4.滑鼠懸停整體旋轉放大</h2>
            <ul>
                <li><img src="http://img1.gtimg.com/autoxingtai/pics/hv1/25/31/204/13273030.jpg"><span>滑鼠懸停整體旋轉放大</span></li>
                <li><img src="http://img1.gtimg.com/autoxingtai/pics/hv1/25/31/204/13273030.jpg"><span>滑鼠懸停整體旋轉放大</span></li>
                <li><img src="http://img1.gtimg.com/autoxingtai/pics/hv1/25/31/204/13273030.jpg"><span>滑鼠懸停整體旋轉放大</span></li>
                <li><img src="http://img1.gtimg.com/autoxingtai/pics/hv1/25/31/204/13273030.jpg"><span>滑鼠懸停整體旋轉放大</span></li>
            </ul>
        </div>
        <div style="clear:both"></div>
        <div class="style5">
            <h2>5.滑鼠懸停整體上升</h2>
            <ul>
                <li><img src="http://img1.gtimg.com/autoxingtai/pics/hv1/25/31/204/13273030.jpg"><span>滑鼠懸停整體上升</span></li>
                <li><img src="http://img1.gtimg.com/autoxingtai/pics/hv1/25/31/204/13273030.jpg"><span>滑鼠懸停整體上升</span></li>
                <li><img src="http://img1.gtimg.com/autoxingtai/pics/hv1/25/31/204/13273030.jpg"><span>滑鼠懸停整體上升</span></li>
                <li><img src="http://img1.gtimg.com/autoxingtai/pics/hv1/25/31/204/13273030.jpg"><span>滑鼠懸停整體上升</span></li>
            </ul>
        </div>
        <div style="clear:both"></div>
        <div class="style6">
            <h2>6.滑鼠懸停心臟咔咔跳</h2>
            <ul>
                <li><img src="http://img1.gtimg.com/autoxingtai/pics/hv1/25/31/204/13273030.jpg"><span>滑鼠懸停心臟咔咔跳</span></li>
                <li><img src="http://img1.gtimg.com/autoxingtai/pics/hv1/25/31/204/13273030.jpg"><span>滑鼠懸停心臟咔咔跳</span></li>
                <li><img src="http://img1.gtimg.com/autoxingtai/pics/hv1/25/31/204/13273030.jpg"><span>滑鼠懸停心臟咔咔跳</span></li>
                <li><img src="http://img1.gtimg.com/autoxingtai/pics/hv1/25/31/204/13273030.jpg"><span>滑鼠懸停心臟咔咔跳</span></li>
            </ul>
        </div>
        <div style="clear:both"></div>
        <footer>
            <code>
        放大 修改scale(放大的值)<br />
        旋轉放大 修改rotate(旋轉度數) scale(放大值)<br />
        上下左右移動 修改translate(x軸,y軸)
    </code>
            <br />
            <hr />
        </footer>
    </body>

</html>