一、常规设置:
background: url(图片路径) center center no-repeat;
//要想背景图片完全覆盖,不留白,需要设置background-size
background-size:cover;
//或
background-size:100% 100%;
二、设置渐变色:
//scss编译
background: linear-gradient(to right, rgba(#000, 0), rgba(#000, 0.7));
//非scss编译
background: linear-gradient(to right, red, blue);
三、同时设置背景图片和背景色:
//单一背景色
background: #fff url(背景图路径) no-repeat center bottom;
//渐变背景色
background: url(背景图路径) top center no-repeat,linear-gradient(to right, rgba(#000, 0), rgba(#000, 0.7));
四、设置svg为背景图:
.svg-link {
height: 24px;
width: 24px;
background-size: contain;
margin-right: 16px;
background-image: url(a.svg);
}