在前端中,背景设置可以通过css来实现,以下是一些背景设置属性和用法示例:
1.background-color:设置背景颜色
div{
background-color:red:
}
2.background-image:设置背景图片
div{
background-image:ur1(../book.jpg)
}
3.background-repeat:(设置背景重复模式{默认横纵重复)
div{
background-repeat:repeat
}
4.background-repeat:no-repeat:设置背景图片不重复
div{
background-repeat:no-repeat
}
5.background-repeat:repeat-x:设置背景图片横向重复
div{
background-repeat:repeat-x
}
6.background-repeat:repeat-y:设置背景图片纵向重复
div{
background-repeat:repeat-y
}
7. background-position:设置背景图片位置
方位单词:top center bottom
lefi center right
div{
background-position:top center
}
8. background-position:设置背景图片位置像素值
div{
background-position: 50px 20px;
}
9.background-position: 设置背景图片位置百分比
div{
background-position: 30% 50%;
}
10. background-attachment:设置背景图片固定
div{
background-attachment:fixed
}
11.background-size: cover :设置背景大小
div{
background-size: cover;
}