table中图片展示

在人海里相遇的人终究要还给人海。

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() {
// console.log('mousewheel信息', event);
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;
/*对DIV设置margin:0 auto样式,
是为了让DIV在浏览器中水平居中。布局居中、水平居中,
均加入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>

文章作者: qinwei
文章链接: https://qw-null.github.io/2021/06/06/table中图片展示/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 QW's Blog