css之第三天笔记
1.背景颜色图片及其平铺
<style type="text/css">
div {
height: 300px;
width: 300px;
background-color: pink; /*背景颜色*/
background-image: url(1542373246758.jpeg);/*背景图片 图片要和文件放在同一个文件夹*/
background-repeat: no-repeat;/*是否平铺,默认上下左右都平铺,no-repeat不平铺,repeat上下左右都平铺,repeat-x平铺,repeat-y竖铺*/
}
</style>
2.背景图片位置
1.方向位操作
/*利用方位名称top bottom right left center来更改背景图片位置*/
background-position: center center;
/*默认坐上角 ,方位名称没有顺序*/
/*如果方位名词只写一个,另一个默认为center*/
2.数字操作
background-position: 10px 30px;
3.混搭
background-position: 10px center;
3.背景附着
也就是说背景随着滑轮滚动还是固定不动
background-attachment: fixed;/*默认是scroll,不随着滚轮一起移动*/
4.背景简写
按背景颜色 背景地址 背景 平铺 附着 位置
background: #000 url(pic/OIP.jpg) no-repeat fixed center -25px;