CSS Background

background-color

    background-color: cyan;
    background-color: rgba(0,0,0,0.5);

background-image

    background-image: url("images/car.jpg");

background-repeat

    background-repeat: no-repeat;
属性 说明
repeat 背景图片纵向和横向平铺
no-repeat 背景图片不平铺
repeat-x 背景图片在横向上平铺
repeat-y 背景图片在纵向上平铺

background-position

设置或检索对象的背景图像位置,必须先指定 background-image 属性,默认值(0%, 0%)
如果只指定了一个值,该值用于横坐标,纵坐标默认为50%,第二个值用于纵坐标
该属性定位不受对象的属性(padding)设置影响

  • background-position: length || length
  • background-position: position || position
  • length: 百分数,由浮点数字和单位标识符组成的长度值
  • position: top | center | bottom | left | right
    background-position: center top;
    background-position: center center;
    background-position: right bottom;
    background-position: left;
    background-position: 12px 50px;
    background-position: 10px center;
    background-position: 10px;

background-attachment

  • scroll:背景图片随内容滚动
  • fixed:背景图片固定

background

background:背景颜色 背景图片地址 背景平铺 背景滚动 背景位置

    background: transparent url("car.jpg") repeat-y scroll 50% 0;
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容