CSS背景图和渐变色共存
需求场景是在一个DOM元素上需要背景图和渐变色共存
实现
background: url(/imgextra/i4/1881744325/O1CN01JBktT81hotb8c6Py0_!!1881744325.png) center no-repeat,linear-gradient(to bottom,red,#3c3f40);
效果
代码
<!DOCTYPE html><html><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><title>css背景图和渐变</title><link rel="stylesheet" href=""><style type="text/css">*{padding: 0;margin: 0;}</style></head><body><style type="text/css">h1{height: 400px;text-align: center;background: url(/imgextra/i4/1881744325/O1CN01JBktT81hotb8c6Py0_!!1881744325.png) center no-repeat,linear-gradient(to bottom,red,#3c3f40);line-height: 400px;}</style><h1>css渐变和背景共存</h1></body></html>