background简写设置
当我们给网页添加图片时,css样式一般会使用:
.title {
width: 100%;
height: 500px;
line-height: 50px;
outline: 1px dashed red;
background-color: rgba(255, 0, 0, 2);
background-image: url(./img/ee0bb6c8ab9e26c5bb03c819154ef7cb.jpg);
/* 不要平铺(会产生多个图片 */
background-repeat: no-repeat;
/* 水平居中 */
background-position: center center;
}
其中背景颜色、插入图片、不要平铺、水平居中可以简写为:
background: rgba(255, 0, 0, 2) url(./img/ee0bb6c8ab9e26c5bb03c819154ef7cb.jpg) no-repeat center center;
代码演示:
评论
匿名评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果