国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > CSS > 正文

css3動畫過渡實現鼠標跟隨導航效果

2024-07-11 08:42:13
字體:
來源:轉載
供稿:網友

本篇文章主要介紹了css3動畫過渡實現鼠標跟隨導航效果,分享給大家,具體如下:

鼠標跟隨導航效果

效果知識點:html/css布局思維, div+css講解,css3動畫,盒子模型, 浮動與定位,鼠標事件。

html代碼:

<div class="wrap">            <ul>                <li style="background-position:0px 0px; border-top:1px dotted #ccc;border-left:1px dotted #ccc;"></li>                <li style="background-position:-230px 0px; border-top:1px dotted #ccc"></li>                <li style="background-position:-460px 0px; border-top:1px dotted #ccc"></li>                <li style="background-position:-690px 0px; border-top:1px dotted #ccc"></li>                <li style="background-position:-920px 0px; border-top:1px dotted #ccc"></li>                <li style="background-position:-1150px 0px;border-left:1px dotted #ccc;"></li>                <li style="background-position:-1370px 0px"></li>                <li style="background-position:-1600px 0px"></li>                <li style="background-position:-1830px 0px"></li>                <li style="background-position:-2060px 0px"></li>                <li style="background-position:-2290px 0px;border-left:1px dotted #ccc;"></li>                <li style="background-position:-2520px 0px"></li>                <li style="background-position:-2750px 0px"></li>                <li style="background-position:-2980px 0px"></li>                <li style="background-position:-3210px 0px"></li>            </ul>            <div class="box"></div>

css代碼:

        <style>            *{                margin:0px;                padding:0px;            }            html{                height:100%;            }            body{                width:100%;                height:100%;                background:url("images/wallpaper4.jpg");                background-size:100% 100%;                overflow: hidden;            }            .wrap{                position:relative;                width:1156px;                height:450px;                margin:50px auto;            }            .wrap ul li{                position:relative;                z-index:10;                width:230px;                height:150px;                float:left;                list-style:none;                border-right:1px dotted #ccc;                border-bottom:1px dotted #ccc;                background:url("images/clients.png") no-repeat;                -webkit-transition:1s;                -moz-transition:1s;                -ms-transition:1s;                -o-transition:1s;                transition:1s;            }            .box{                position:absolute;                left:0px;                top:0px;                z-index:2;                width:230px;                height:150px;                background:rgba(0,0,0,.2);                -webkit-transition:1s;                -moz-transition:1s;                -ms-transition:1s;                -o-transition:1s;                transition:1s;            }        </style>

javascript代碼:

    <script>            var oLi = document.getElementsByTagName("li");            var box = document.getElementsByClassName("box")[0];            for (var i = 0;i<oLi.length ;i++ )            {                oLi[i].onmousemove = function(){                    var _left = this.offsetLeft;                    var _top = this.offsetTop;                    box.style.left = _left + "px";                    box.style.top = _top + "px";                    this.style.backgroundPositionY = "-150px";                }                oLi[i].onmouseout = function(){                    this.style.backgroundPositionY = "0px";                }            }        </script>

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 化州市| 通渭县| 仁怀市| 湘阴县| 东明县| 南投市| 常熟市| 南陵县| 浠水县| 凌云县| 丰镇市| 彰化市| 通化县| 太仓市| 泽库县| 施秉县| 宁阳县| 湘西| 宝应县| 红河县| 延津县| 长宁县| 康乐县| 普格县| 神木县| 辽阳市| 武强县| 厦门市| 丽水市| 洛阳市| 鲁山县| 开原市| 六盘水市| 田林县| 金沙县| 平泉县| 通榆县| 马关县| 札达县| 瓮安县| 通城县|