1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
| <!DOCTYPE html> <html lang="en">
<head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <script src="jquery-3.6.0.js"></script> <style> * { margin: 0; padding: 0; }
.box { width: 620px; height: 410px; margin: 100px auto; background-color: rgb(0, 0, 0); padding: 10px; }
.imgbox { width: 200px; height: 200px; float: left; margin-right: 10px; }
.imgbox:nth-child(3) { margin-right: 0; }
.imgbox:nth-child(6) { margin-right: 0; }
.imgbox:nth-child(n+4) { margin-top: 10px; }
.imgbox img { width: 100%; height: 100%; } </style> </head>
<body> <div class="box"> <div class="imgbox"> <img src="./images/01.jpg" alt="" srcset=""> </div> <div class="imgbox"> <img src="./images/02.jpg" alt="" srcset=""> </div> <div class="imgbox"> <img src="./images/03.jpg" alt="" srcset=""> </div> <div class="imgbox"> <img src="./images/04.jpg" alt="" srcset=""> </div> <div class="imgbox"> <img src="./images/05.jpg" alt="" srcset=""> </div> <div class="imgbox"> <img src="./images/06.jpg" alt="" srcset=""> </div> </div>
<script>
$(function() { $(".imgbox").mouseover(function(){ $(this).siblings().stop().fadeTo(300,0.5) }) $(".imgbox").mouseout(function(){ $(this).siblings().stop().fadeTo(300,1) }) }) </script> </body>
</html>
|