css 背景

背景图片

  • repeat:背景图像在纵向横向平铺

​ background-repeat: repeat;

  • no-repear:背景图像不平铺

​ background-repeat: no-repeat;

  • repeat-x:背景图像横向平铺

​ background-repeat: repeat-x;

  • repeat-y:背景图像纵向平铺

​ background-repeat: repeat-y;

​ background-position: x y;

  • 方位名词:top,left,bottom,right,center

​ 精确单位:px 百分数

  • 跟顺序无关

​ 如果我就指定一个方位名词,别一个省略,则第二个值默认居中对齐

​ background-position:bottom;

  • 参数是精确单位,第一个肯定是x坐标,第二个一定是y坐标

​ .tp{

​ width: 800px;height: 400px;

​ background: url(logo.png) no-repeat blue right 100px;

  • 如果指定一个数值,那么该数值一定是x坐标,另一个垂直居中 */

​ background-position: 20px;

  • 混合单位:第一个是x坐标,第二个是y坐标 */

​ background-position: right 100px;

背景固定

  -  scroll:背景图像市跟随对象内容滚动

  ​       background-attachment: scroll;

  - fixed:背景图像固定

  ​      background-attachment: fixed;

  **背景透明**

     -  rgba:红 绿 蓝 alpha:透明度 取范围0-1之间

     ​       

     ​      background: rgba(0, 0, 0, .3);

设置图片大小

  • 设置图片大小

​ background-size: auto;

  • 默认值,不改变背景颜色的高度和宽度
  • 第一个值为宽,第二个值为高,当设置一个值时;将其作为图片宽度等比缩放

​ background-size: 100px 50px;

  • 0%-100%之间任意一个值,将背景图片宽高按百分比显示,当设置一个值时也可以作为图片宽度来等比缩放

​ background-size: 10% ;

  • 将背景图片等比缩放填满整个容器

​ background-size: cover;

  • 将背景图片等比缩放至某一边紧贴容器边缘

​ background-size: contain;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值