0
点赞
收藏
分享

微信扫一扫

商品缩略图效果 js 230218

非衣所思 2023-02-18 阅读 62


布局

商品缩略图效果 js 230218_3c

右超出区切掉

css属性

overflow:hidden

对容器盒子使用


左侧小遮罩层

与前面学的根随的盒子是一样的效果

商品缩略图效果 js 230218_3c_02


关于小盒子的位置校正

商品缩略图效果 js 230218_2d_03

遮罩层最大可移动范围

max_x = 大盒子宽 - 小盒子宽

max_y = 大盒子高 - 小盒子高


需要设置小盒子的上下左右可移动范围

如果超出范围,就校正一下


右侧的图片的移动


商品缩略图效果 js 230218_2d_04


演练结构代码


<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
.smallImg{
position: absolute;
left: 50px;
top: 50px;
width: 200px;
height: 200px;
border: 1px solid black;
}
.smallImg img{
width: 100%;
height: 100%;

}
.smallImg .mask{
width: 120px;
height: 120px;
background-color: rgba(246, 213, 20,0.5);
position: absolute;
left: 0;
top: 0;
}
.bigImg{
position: absolute;
width: 400px;
height: 400px;
border: 1px solid black;
left: 300px;
top: 50px;
overflow: hidden;
}
.bigImg img{
width: 166.66%;
height: 166.66%;
}

</style>
</head>
<body>


<div class="smallImg">
<img src="https://img-blog.csdnimg.cn/62dc093190b849febfee713c7dd2ddc0.jpeg" alt="">
<div class="mask"></div>
</div>
<div class="bigImg">
<img src="https://img-blog.csdnimg.cn/62dc093190b849febfee713c7dd2ddc0.jpeg" alt="">
</div>

<script>

</script>
</body>
</html>


举报

相关推荐

0 条评论