变形的图:
![](https://img-blog.csdnimg.cn/e10ab7a1129e4467b3f5d4baab836ac1.png)
html:
<div class="lamp-img-panel" ></div>
css:
.lamp-img-panel {
width: 100%;
height: 40vh;//高度40vh相当于占整个屏幕高度的40%
background: url('https://eventimg.oss-cn-shenzhen.aliyuncs.com/activity_h5/fbecGame/home_bg2.png')
no-repeat center center;
background-size: 100% 100%;
}
修改后的效果:
![](https://img-blog.csdnimg.cn/29a33bbfb1fa4b67835fcb020006ce59.png)
html:
<div class="lamp-img-panel" :style="{'height': `${logoHeight}px`}"></div>
css:
.lamp-img-panel {
width: 100%;
// height: 40vh;//高度改为动态高度,写在行内
background: url('https://eventimg.oss-cn-shenzhen.aliyuncs.com/activity_h5/fbecGame/home_bg2.png')
no-repeat center center;
background-size: 100% 100%;
}
js:
<script>
export default {
data() {
return {
logoHeight: window.innerWidth * (1304 / 1500),//1304为图片本身的高度,1500为图片本身的宽度
};
},
};
</script>