1. 程式人生 > 程式設計 >jQuery實現滑鼠移入顯示蒙版效果

jQuery實現滑鼠移入顯示蒙版效果

本文例項為大家分享了jQuery滑鼠移入顯示蒙版的具體程式碼,供大家參考,具體內容如下

效果展示:

具體程式碼:

<ul id="fourth_tab">
  <li>
   <img src="img/camera_green.png" alt="綠色相機" class="camera">
   <p class="title"><span>攝影小白成長記</span></p>
   <p>The best preparation for tomorrow is doing your best today.</p>
  </li>
  <li style="background-color: red">
   <div class="show_more"><a href="html/test.html" >點選檢視更多</a></div>
   <img src="img/bus.webp" alt="公交車">
  </li>
  <li style="background-color: red">
   <div class="show_more"><a href="html/test.html" >點選檢視更多</a></div>
   <img src="img/life.png" alt="落葉">
  </li>
 </ul>
#fourth_tab li{
 position: relative;
 border-radius: 6px;
}
.show_more{
 width: 100%;
 height: 100%;
 line-height: 230px;
 background-color: #9f594d;
 position: absolute;
 display: none;
 font-size: 22px;
 font-weight: bolder;
 letter-spacing: 4px;
 cursor: pointer;
}
.show_more a{
 text-decoration: none;
 color: #fbfff9;
}
$('#fourth_tab li').mouseenter(function(){
 $(this).find('.show_more').slideDown(200);
});

$('#fourth_tab li').mouseleave(function(){
 $(this).find('.show_more').slideUp(200);
});

個人筆記:

1.這裡主要使用到jQuery的slideUp()、slideDown()函式
2.在js程式碼中,使用$(this)來做限制。滑鼠移入第二張圖片,那麼這張圖片上面顯示蒙版,其他的圖片不顯示

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支援我們。