当前位置:网站首页>放大镜子效果图
放大镜子效果图
2022-06-11 07:42:00 【yibucuo】

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
* {
margin: 0;
padding: 0;
}
#wrap {
position: relative;
height: 600px;
width: 400px;
margin-left: 200px;
border: 2px solid blue;
}
#wrap #bigContent {
position: absolute;
height: 400px;
width: 400px;
left: 500px;
top: 0;
overflow: hidden;
display: none;
}
#wrap #bigContent img {
height: 1000px;
width: 1000px;
display: block;
position: absolute;
left: -400px;
}
#wrap #content {
position: relative;
height: 400px;
width: 400px;
margin-bottom: 20px;
}
#content #shadow {
height: 160px;
width: 160px;
position: absolute;
background-color: rgba(66, 166, 166, 0.4);
left: 0;
top: 0;
display: none;
}
#wrap #content img {
height: 400px;
width: 400px;
}
#footer {
height: 100px;
width: 400px;
list-style: none;
}
#footer li {
float: left;
width: 98px;
height: 98px;
border: 1px solid #cdcdcd;
line-height: 98px;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
}
#footer li img {
width: 90px;
height: 90px;
}
#footer li:hover {
border: 1px solid black;
}
</style>
</head>
<body>
<div id="wrap">
<div id="content">
<img src="img/small1.jpg" id="smallImg"/>
<div id="shadow"></div>
</div>
<div id="bigContent">
<img src="img/big1.jpg" id="bigImg"/>
</div>
<ul id="footer">
<li><img src="img/small1.jpg" alt="" data-src="img/big1.jpg"></li>
<li><img src="img/small2.jpg" alt="" data-src="img/big2.jpg"></li>
<li><img src="img/small3.jpg" alt="" data-src="img/big3.jpg"></li>
<li><img src="img/small4.jpg" alt="" data-src="img/big4.jpg"></li>
</ul>
</div>
</body>
<script>
var liList = document.querySelector("#footer").querySelectorAll("li");
var smallImg = document.querySelector("#smallImg");
var content = document.querySelector("#content");
var shadow = document.querySelector("#shadow");
var bigImg = document.querySelector("#bigImg");
var wrap = document.querySelector("#wrap");
var bigContent = document.querySelector("#bigContent");
for (var i = 0; i < liList.length; i++) {
liList[i].onmouseover = function () {
var img = this.querySelector("img")
smallImg.src = img.src;
bigImg.src = img.getAttribute("data-src");
}
}
content.onmousemove = function (e) {
var evt = window.event || e;
var x = evt.pageX - getStyle(shadow, "width") / 2 - getStyle(wrap, "margin-left");
var y = evt.pageY - getStyle(shadow, "height") / 2 - getStyle(wrap, "margin-top");
if (x <= 0) {
x = 0;
}
if (y <= 0) {
y = 0;
}
var maxX = getStyle(content, "width") - getStyle(shadow, "width");
if (x >= maxX) {
x = maxX;
}
var maxY = getStyle(content, "height") - getStyle(shadow, "height");
if (y >= maxY) {
y = maxY;
}
var bigX = -(getStyle(bigImg, "width") * x / getStyle(content, "width"));
var bigY = -(getStyle(bigImg, "height") * y / getStyle(content, "height"));
shadow.style.left = x + "px";
shadow.style.top = y + "px";
bigImg.style.left = bigX + "px";
bigImg.style.top = bigY + "px";
shadow.style.display = "block";
bigContent.style.display = "block";
}
content.onmouseout = function () {
shadow.style.display = "none";
bigContent.style.display = "none";
}
function getStyle(obj, attr) {
if (obj.currentStyle) {
return parseInt(obj.currentStyle[attr]);
} else {
return parseInt(window.getComputedStyle(obj)[attr]);
}
}
</script>
</html>
边栏推荐
- How to prepare for the new PMP syllabus exam?
- nosqlzoo刷题-1
- Bidirectional linked list simple template (pointer version)
- Post-processing of ffmpeg miscellaneous notes
- C language judging big end and small end [consortium or pointer] big end and small end conversion
- 【AtCoder1984】Wide Swap (拓扑排序转化)
- 【软件测试】这样的简历已经刷掉了90%的面试者
- C language to achieve minesweeping games
- 【CodeForces1019E】Raining season(边分治+斜率优化)
- I/o multiplexing - select/poll/epoll
猜你喜欢

C language inherits memory management mechanism (unfinished)

Sdl-2 thread logic

Simple configuration of vscade

2022.5.30-6.5 AI行业周刊(第100期):三年时光

Software testing weekly (issue 75): only when you look down, can you see your true self.
![[compilation principle] 05- syntax guided semantic computing -- Semantic Computing Based on translation mode](/img/7d/f3ba5a69e182160a5e1b51c7d9aaf9.png)
[compilation principle] 05- syntax guided semantic computing -- Semantic Computing Based on translation mode
![[codeforces1019e] raining season](/img/8e/4a96954ee7dae5f81eaae05b5a075b.png)
[codeforces1019e] raining season

Classification of MNIST datasets with keras

【软件测试】这样的简历已经刷掉了90%的面试者

Use of wordcloud
随机推荐
MFC auxiliary CString string splicing
[atcoder1981] short diameter (graph theory thinking)
二本畢業,銀行外包測試工作 4 個月有餘。聊聊一些真實感受 ...
[atcoder1980] mystious light (mathematical simulation)
C memory alignment
QT table display data
Sort - select sort
Rabin-Miller素数测试
【AtCoder1980】Mysterious Light(数学模拟)
Deux diplômés, la Banque a externalisé le travail d'essai pendant plus de quatre mois. Parler de vrais sentiments...
【CodeForces1019E】Raining season(边分治+斜率优化)
Long dialogue in June 2017
Several transaction modes of Seata
After 4 years of naked resignation from the test, the test post of 15K interview was rubbed on the ground, and the result made me collapse and cry
2022 low voltage electrician operation certificate test question simulation test platform operation
[IOT] project management: how to build a better cross functional team?
Sdl-2 thread logic
零基础自学SQL课程 | OUTER JOIN外连接
Compound RateModel合约解析
[atcoder1984] wide swap