template
<template >
<div class="main">
</div>
</template>
style设置
<style scoped >
.main {
width: 210vh;
height: 100vh;
/* background-image: linear-gradient(to top left, #e5a8d5, #00efff, #e5a8d5); */
background-image: url("/src/assets/bgImage_DPI1000.jpg");
/* 背景图垂直、水平均居中 */
background-position: center center;
/* 背景图不平铺 */
background-repeat: no-repeat;
/* 当内容高度大于图片高度时,背景图像的位置相对于viewport固定 */
background-attachment: fixed;
/* 让背景图基于容器大小伸缩 */
background-size: cover;
display: flex;
justify-content: center;
}
</style>
展示