鼠标悬浮--遮罩层

33 篇文章 0 订阅

鼠标悬浮--遮罩层

页面代码:

 <ul class="site-tag fl">
        <li><a data-title="科学" href="#"><i style="background-image: url(images/xiaozhan/main_ojls_1aa6000200891260.jpg)">
        </i><span class="tag-tit">科学</span> </a></li>
        <li><a data-title="动漫" href="#"><i style="background-image: url(images/xiaozhan/main_NH8v_2e310001ebd1118e.jpg)">
        </i><span class="tag-tit">动漫</span> </a></li>
        <li><a data-title="生活" href="#"><i style="background-image: url(images/xiaozhan/main_OtnR_43a60000050a118c.jpg)">
        </i><span class="tag-tit">生活</span> </a></li>
        <li><a data-title="插画" href="#"><i style="background-image: url(images/xiaozhan/main_UD3z_2e510002074f118e.jpg)">
        </i><span class="tag-tit">插画</span> </a></li>
        <li><a data-title="音乐" href="#"><i style="background-image: url(images/xiaozhan/main_krFk_6323000018bd125d.jpg)">
        </i><span class="tag-tit">音乐</span> </a></li>
        <li><a data-title="自然" href="#"><i style="background-image: url(images/xiaozhan/main_UAbs_764f0001ff601190.jpg)">
        </i><span class="tag-tit">自然</span> </a></li>
</ul>

js代码:

<script type="text/javascript">
        $(function () {
            //遮罩层,鼠标移动上去高度变化,变清晰
            var $site_li = $(".site-tag li");
            $site_li.hover(function () {
                var indexs = $site_li.index(this);
                $(this).css("height", "90").find(".tag-tit").css("top", "30").css("color", "#fff");
                //获取当前点击li元素在全部li元素中的索引
                //alert(indexs+1);
                $(this).prev().css("height", "30");
                $(this).next().css("height", "30");
            }, function () {
                $site_li.css("height", "50");
            });
        });
 </script>

css代码:

ul li{ list-style:none;}
.site-tag{ width:200px; overflow:hidden; z-index:5;}
.site-tag li{ position:relative; width:200px; height:50px; margin-bottom:1px; overflow:hidden; 
              transition:height 0.5s ease; -webkit-transition:height 0.5s ease; 
              -moz-transition:height 0.5s ease; -o-transition:height 0.5s ease;}
.site-tag li a { color: #666; font-size: 16px; font-weight: bold;line-height: 50px;}
.site-tag li i{ display:block; height:90px; background-position:center center;
                opacity:0.3; filter:alpha(opacity=3);  /*设置透明度*/
                -webkit-transition:opacity 0.5 ease;   /**/
                -webkit-filter:grayscale(60%);         /**/
               }
.site-tag li:hover i { opacity:0.9; -webkit-filter:grayscale(0%); transition:opacity 0.5s ease;}
.tag-tit{ display:block; height:100px; width:700px; color:#666; font-size:14px;}                 
.site-tag li .tag-tit{ position:absolute; top:0px; left:10px; text-shadow:1px 1px 1px rgb(0,0,0,0.1);}
a:hover .tag-tit{ text-shadow:1px 1px 1px rgb(0,0,0,0.5);}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值