1. 背景图片过渡
background: url('http://xxx.jpg'), linear-gradient(to bottom, rgba(6, 22, 27, 1.0) 85%, rgba(243, 243, 243, 1.0) 100%);
2. 背景图片固定,实现视觉差效果
background-attachment: fixed;
问题: 在小程序真机中不起作用
解决方式:
.header::before {
content: '';
// display: block;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 500rpx;
background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 20%, rgba(243, 243, 243, 1.0) 100%), url('http://xxx.jpg');
background-size: contain;
background-repeat: no-repeat;
}
.header {
padding-top: 380rpx;
width: 100%;
position: relative;
// background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 20%, rgba(243, 243, 243, 1) 100%), url('https://img.jszero.cn/picgo/233cf0f156538fa06510f802e0c6caa5.jpg');
// background-attachment: fixed;
// background-size: contain;
// background-repeat: no-repeat;
}
.main{
position: relative;
background-color: #f5f5f5;
}
实现效果:
image.png