html文件:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>突出展示案例</title> <style type="text/css"> * { margin: 0; padding: 0; } ul { list-style: none; } body { background: #000; } .wrap { margin: 100px auto 0; 446px; height: 394px; padding:10px 0 0 10px; background: #000; overflow: hidden; border: 1px solid #fff; } .wrap li { float: left; margin: 0 10px 10px 0; } .wrap img { display: block; border: 0; } </style> <script src="https://cdn.staticfile.org/jquery/2.0.0/jquery.min.js"></script> <script type="text/javascript"> $(function(){ //mouseover:鼠标经过事件 //mouseout:鼠标离开事件 //mouseenter:鼠标进入事件 //mouseleave:鼠标离开事件 $(".wrap>ul>li").mouseenter(function(){ $(this).css("opacity","1").siblings().css("opacity","0.4"); }); $(".wrap").mouseleave(function(){ //让所有的li都变亮 //$("li"); //$(".wrap li"); //$(".wrap>ul>li") //$(this).children().children("li"); $(this).find('li').css("opacity", 1); }) }) </script> </head> <body> <div class="wrap"> <ul> <li><a href="#"><img src="https://images.cnblogs.com/cnblogs_com/luwn/1701485/t_200415035849d3a83afb3f3b8c1bb4ac77a2e61a5eae.jpg" alt=""></a></li> <li><a href="#"><img src="https://images.cnblogs.com/cnblogs_com/luwn/1701485/t_200415035849d3a83afb3f3b8c1bb4ac77a2e61a5eae.jpg" alt=""></a></li> <li><a href="#"><img src="https://images.cnblogs.com/cnblogs_com/luwn/1701485/t_200415035849d3a83afb3f3b8c1bb4ac77a2e61a5eae.jpg" alt=""></a></li> <li><a href="#"><img src="https://images.cnblogs.com/cnblogs_com/luwn/1701485/t_200415035849d3a83afb3f3b8c1bb4ac77a2e61a5eae.jpg" alt=""></a></li> <li><a href="#"><img src="https://images.cnblogs.com/cnblogs_com/luwn/1701485/t_200415035849d3a83afb3f3b8c1bb4ac77a2e61a5eae.jpg" alt=""></a></li> <li><a href="#"><img src="https://images.cnblogs.com/cnblogs_com/luwn/1701485/t_200415035849d3a83afb3f3b8c1bb4ac77a2e61a5eae.jpg" alt=""></a></li> </ul> </div> </body> </html>