有次UI给我提出了bug说我的登录页的背景图变形了,后来查了下正确的背景图设置,如下:
.login-box {width: 100%;height: 100%;background: url("../../assets/img/login_bg.png") no-repeat;background-size: cover;background-attachment: fixed;min-height: 100vh;}
background: url(“…/…/assets/img/login_bg.png”) no-repeat 设置背景图片地址 no-repeat背景图像将仅显示一次,在水平和垂直方向上不重复;
background-size:cover; 图片等比例扩大。背景图像的某些部分也许无法显示在背景定位区域中,图片多出的部分则会被截掉。
这里还可以设置:
background-size: contain; 图片比例不变,把图像图像扩展至最大尺寸,容器可能会有留白区域
background-size: 100% 100%; 使图片占满整个页面。
background-attachment:fixed 当页面的其余部分滚动时,背景图像不会移动