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 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
| <!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>Table中横向图片展示</title> </head>
<body> <h4>Table横向多个图片展示</h4> <p>每个表格由 table 标签开始。</p> <p>每个表格行由 tr 标签开始。</p> <p>每个表格数据由 td 标签开始。</p> <div> <table class="table"> <thead> <tr> <th>序号</th> <th>名称</th> <th>图片展示</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>阿里</td> <td> <div class="table_img" onmousewheel="handler()"> <img src="https://cdn.jsdelivr.net/gh/qw-null/BlogImages/pexels-pixabay-2150.jpg" alt="" class="imgAuto"> <img src="https://cdn.jsdelivr.net/gh/qw-null/BlogImages/pexels-scott-webb-1098520.jpg" alt="" class="imgAuto"> <img src="https://cdn.jsdelivr.net/gh/qw-null/BlogImages/pexels-pixabay-2150.jpg" alt="" class="imgAuto"> <img src="https://cdn.jsdelivr.net/gh/qw-null/BlogImages/pexels-scott-webb-1098520.jpg" alt="" class="imgAuto"> <img src="https://cdn.jsdelivr.net/gh/qw-null/BlogImages/pexels-pixabay-2150.jpg" alt="" class="imgAuto"> <img src="https://cdn.jsdelivr.net/gh/qw-null/BlogImages/pexels-scott-webb-1098520.jpg" alt="" class="imgAuto"> <img src="https://cdn.jsdelivr.net/gh/qw-null/BlogImages/pexels-pixabay-2150.jpg" alt="" class="imgAuto"> <img src="https://cdn.jsdelivr.net/gh/qw-null/BlogImages/pexels-scott-webb-1098520.jpg" alt="" class="imgAuto"> <img src="https://cdn.jsdelivr.net/gh/qw-null/BlogImages/pexels-pixabay-2150.jpg" alt="" class="imgAuto"> <img src="https://cdn.jsdelivr.net/gh/qw-null/BlogImages/pexels-scott-webb-1098520.jpg" alt="" class="imgAuto"> <img src="https://cdn.jsdelivr.net/gh/qw-null/BlogImages/pexels-pixabay-2150.jpg" alt="" class="imgAuto"> </div> </td> </tr> <tr> <td>2</td> <td>腾讯</td> <td></td> </tr> <tr> <td>3</td> <td>百度</td> <td></td> </tr> </tbody> </table> </div>
</body> <script type="text/javascript"> function handler() { var detail = event.wheelDelta || event.detail; var item = event.currentTarget; var moveForwardStep = 1; var moveBackStep = -1; var step = 0; if (detail < 0) { step = moveForwardStep * 100; } else { step = moveBackStep * 100; } item.scrollLeft += step;
}
</script> <style> .table { border-collapse: collapse; margin: 0 auto;
text-align: center; }
.table td, .table th { border: 1px solid #cad9ea; color: #666; height: 80px; width: 350px; }
table thead th { background-color: #CCE8EB; width: 100px; }
.table tr:nth-child(odd) { background: #fff; }
.table tr:nth-child(even) { background: #F5FAFA; }
.imgAuto { display: inline-block; height: 80px; max-width: 350px; }
.table_img { height: 100px; width: 350px; overflow-y: auto; white-space: nowrap; }
.table_img::-webkit-scrollbar { width: 3px; height: 10px; }
.table_img::-webkit-scrollbar-thumb { border-radius: 10px; background-color: rgba(159, 160, 162, 0.8); }
.table_img::-webkit-scrollbar-track { border-radius: 10px; } </style>
</html>
|