JavaScriptを使わないで表示する一番簡単な方法
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 |
<!doctype html> <html> <head> <meta charset="UTF-8"> <title>サムネイルをhoverすると画像が変わる</title> <style> @charset "UTF-8"; /* CSS Document */ html, body, ul, li, h1, h2, p { margin: 0; padding: 0; line-height: 1.0; } ul { list-style-type: none; } img { vertical-align: bottom; } .container { width: 950px; margin: 0px auto; } ul { display: flex; } </style> </head> <body> <div class="container"> <p class="mainImg"><img src="img/cover.jpg" alt="" id="mainImg"></p> <ul class-"thumnail"> <li><img src="img/s01.jpg" alt="" onmouseover="mainImg.src='img/01.jpg'" onmouseout="mainImg.src='img/cover.jpg'"></li> <li><img src="img/s02.jpg" alt="" onmouseover="mainImg.src='img/02.jpg'" onmouseout="mainImg.src='img/cover.jpg'"></li> <li><img src="img/s03.jpg" alt="" onmouseover="mainImg.src='img/03.jpg'" onmouseout="mainImg.src='img/cover.jpg'"></li> <li><img src="img/s04.jpg" alt="" onmouseover="mainImg.src='img/04.jpg'" onmouseout="mainImg.src='img/cover.jpg'"></li> <li><img src="img/s05.jpg" alt="" onmouseover="mainImg.src='img/05.jpg'" onmouseout="mainImg.src='img/cover.jpg'"></li> </ul> </div> </body> </html> |
参考サイト
https://web-felica.hatenablog.com/entry/2019/05/16/%E7%94%BB%E5%83%8F%E7%BD%AE%E6%8F%9B