JavaScript仿百度图片浏览效果(转载)

时间:2019-06-12
本文章向大家介绍JavaScript仿百度图片浏览效果(转载),主要包括JavaScript仿百度图片浏览效果(转载)使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

转载来源:https://www.jb51.net/article/98030.htm

这是一个非常好的案例,然而jquery的时代正在徐徐关闭。

当你调整浏览器宽高,你会发现它不是自适应的。当你想把它放到elementUI项目中是,你发现不行!

如果你项目采用了vue和elementUI,建议以找找vue实现版本,或者单纯js版本。

本文实例为大家分享了js图片浏览效果的具体代码,供大家参考,具体内容如下

在线地址:http://www.hui12.com/nbin/demo/imgskim/index.html
https://nbin2008.github.io/demo/imgskim/index.html

index

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
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>仿百度图片浏览</title>
    <link rel="stylesheet" type="text/css" href="css/index.css"/>
    <script src="js/jquery-2.1.0.js"></script>
    <script src="js/data.js"></script>
    <script src="js/handleImage.js"></script>
    <script src="js/index.js"></script>
  </head>
  <body>
    <div class="container1">
      <div class="main1">
        <!-- 图片显示 -->
        <div class="showImg1">
          <a href="javascript:;" class="showImg1_btnLeft"></a>
          <a href="javascript:;" class="showImg1_btnRight"></a>
          <div class="imgBox1">
            <img src="" class="img1"/>
          </div>
        </div>
        <!-- 图片选择 -->
        <div class="chooseImg1_box">
          <div class="navList1">
            <span class="btnImgList">图片列表<i></i></span>
            <span class="btnImgScale">
              <a href="javascript:;" class="scaleAdd1">+</a>
              <b class="scale1">100%</b>
              <a href="javascript:;" class="scaleReduce1">-</a>
            </span>
            <span class="btnImgInit1">原始尺寸</span>
            <span class="btnImgFullScreen">全屏</span>
            <span>其他</span>
            <span>其他</span>
          </div>
          <div class="boxLimit1">
            <a href="javascript:;" class="chooseImg1_btnLeft"></a>
            <div class="imgListBox1">
              <ul class="imgList1"></ul>
            </div>
            <a href="javascript:;" class="chooseImg1_btnRight"></a>
          </div>
            
        </div>
      </div>
      <div class="sider1">
        <p class="pTroTit1"></p>
        <p class="pTroName1"></p>
      </div>
    </div>
    <!-- 全屏 -->
    <div class="container2">
      <div class="chooseTimeBox">
        <select class="select">
          <option value="2">2s</option>
          <option value="3">3s</option>
          <option value="5">5s</option>
        </select>
        <a href="javascript:;" class="btnStart">开始</a>
        <a href="javascript:;" class="btnStop">||</a>
      </div>
      <!-- main -->
      <div class="imgBox2">
        <img src="" class="img2" />
      </div>
      <a href="javascript:;" class="showImg2_btnLeft"></a>
      <a href="javascript:;" class="showImg2_btnRight"></a>
      <div class="imgListBox2">
        <ul class="imgList2"></ul>
      </div>
      <a href="javascript:;" class="chooseImg2_btnLeft aBtn" ></a>
      <a href="javascript:;" class="chooseImg2_btnRight aBtn"></a>
      <a href="javascript:;" class="btnExitFullScreen">x</a>
    </div>
  </body>
</html>

css

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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
/* common */
*{
  margin: 0; padding: 0;
}
body,html{
  font-family: "微软雅黑"; font-size: 12px; overflow: hidden;
}
li{
  list-style: none;
}
a{
  text-decoration: none; color: #000;
}
.btnIco{
  background: url(../images/btn.png);
}
b{
  font-weight: normal;
}
i{
  font-style: normal;
}
  
/* container1 */
.container1{
  width: 100%; height: 100%; background-color: #f6f6f6; position: absolute; min-width: 1000px; min-height: 400px; -display: none;
}
.main1{
  position: absolute; width: calc(100% - 310px); height: calc(100% - 5px); left: 0; top: 5px; background-color: #fff;
}
.sider1{
  position: absolute; width: 300px; margin-left: 10px; height: calc(100% - 5px); overflow-x: hidden; overflow-y: auto; top: 5px; right: 0px; background-color: #fff;
}
.showImg1{
  width: 100%; position: relative;
}
.showImg1 a{
  position: absolute; width: 70px; height: 100%; top: 0; background-color: #fff; transition: all 0.5s;
}
.showImg1 a:hover{
  background-color: #e6e6e6;
}
.showImg1 a:before{
  content: ''; display: block; position: absolute; width: 40px; height: 72px; background: url(../images/btn.png); left: calc(50% - 20px); top: calc(50% - 31px);
}
.showImg1 .showImg1_btnLeft{
  left: 0;
}
.showImg1 .showImg1_btnRight{
  right: 0;
}
.showImg1 .showImg1_btnLeft:before{
  background-position: 0 -87px;
}
.showImg1 .showImg1_btnLeft:hover:before{
  background-position: -46px -87px;
}
.showImg1 .showImg1_btnRight:before{
  background-position: 0 0;
}
.showImg1 .showImg1_btnRight:hover:before{
  background-position: -46px 0;
}
.showImg1 .imgBox1{
  position: absolute; width: calc(100% - 144px); height: calc(100% - 4px); left: 72px; top: 2px; overflow: hidden;

原文地址:https://www.cnblogs.com/hao-1234-1234/p/11011396.html