背景练习和雪碧图

一、有关背景

  1. background - color

  2. background - size :

    - 设置图片大小,宽+高(只写一个,另一个默认为auto)

      - cover:图片比例不变,将元素铺满,但有可能显示不全;

      - contain :图片比例不变,完整显示图片

  3. background - image

    - url()

  4. background - repeat

    - none / repeat - x / repeat - y

  5. background - position:

    - 设置两个值,如果设置一个,另一个默认为 center

  6. background - clip

    - 可选值:border - box;padding-box; content - box 

  7. background - origin

    - 可选值与上同

  8. background - attachment

    - scroll ;fixed

二、雪碧图(CSS- Sprite)

  1. 它用来解决图片显示时的闪烁问题;可以降低请求次数,加快访问速度,提升用户体验

  2. 将多个小图片保存为一个大图片,然后通过调整 background - position 来分别显示

posted @ 2022-04-06 11:29  故渊ccx  阅读(47)  评论(0)    收藏  举报