baixuezhemei

如果背景比较小 元素比较大 默认的是背景图片平铺的

background-image: url(52.jpg);

设置背景图片不重复

background-repeat: no-repeat;

固定背景图片

background-attachment: fixed;

背景图片大于元素的大小的时候 只会显示图片部分 左上部分


背景图片的位置 横向位置 纵向位置 设置成具体值 背景图片向左移动100px 向上移动100px

background-position: -100px --100px;

设置背景图片在中间

background-position: 50% 50%;

背景图片在右下

background-position: 100% 100%; background-position: 0% 0%;

背景图片大小 宽 高

background-size: 200px 200px ;

把元素平铺

background-size: 100% 100%;

较短的一边平铺 另一边等比例缩放

background-size: cover;

长的一边平铺 另一边等比例缩放

background-size: contain; background-position: 100% 100%;

分类:

技术点:

相关文章:

  • 2021-05-11
  • 2021-08-29
  • 2021-07-06
  • 2021-05-28
  • 2022-01-02
猜你喜欢
  • 2021-11-24
  • 2022-01-28
  • 2021-12-16
  • 2021-12-06
  • 2022-01-01
  • 2021-04-10
  • 2022-01-22
相关资源
相似解决方案