Home > Web Front-end > HTML Tutorial > CSS background 属性_html/css_WEB-ITnose

CSS background 属性_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:44:19
Original
1150 people have browsed it

CSS Reference Manual

Example

How to set all background properties in one declaration:

body  {   background: #00FF00 url(bgimage.gif) no-repeat fixed top;  }
Copy after login

Try it yourself

Browser support

IE Firefox Chrome Safari Opera
         

All browsers support the background attribute.

Note: IE8 and earlier browsers do not support multiple background images for one element.

Note: IE7 and earlier browsers do not support "inherit". IE8 requires !DOCTYPE. IE9 supports "inherit".

Definition and Usage

Background shorthand property sets all background properties in one declaration.

You can set the following properties:

  • background-color
  • background-position
  • background-size
  • background-repeat
  • background-origin
  • background-clip
  • background-attachment
  • background-image
  • If one of the values ​​is not set, it will not There will be problems, such as background:#ff0000 url('smiley.gif'); is also allowed.

    It is generally recommended to use this attribute rather than using individual attributes individually, as it is better supported in older browsers and requires fewer letters to be typed.

    默认值: 继承性: 版本: JavaScript 语法:
    not specified
    no
    CSS1 CSS3
    object.style.background="white url(paper.gif) repeat-y"

    Possible values

    值 描述 CSS
    background-color 规定要使用的背景颜色。 1
    background-position 规定背景图像的位置。 1
    background-size 规定背景图片的尺寸。 3
    background-repeat 规定如何重复背景图像。 1
    background-origin 规定背景图片的定位区域。 3
    background-clip 规定背景的绘制区域。 3
    background-attachment 规定背景图像是否固定或者随着页面的其余部分滚动。 1
    background-image 规定要使用的背景图像。 1
    inherit 规定应该从父元素继承 background 属性的设置。 1

    Try it yourself - Example

    All background properties in one declaration This example demonstrates how to use shorthand properties to set all background properties in a single declaration.

    Related Pages

    CSS Tutorial: CSS Background

    CSS3 Tutorial: CSS3 Background

    HTML DOM Reference Manual: background attribute

    Related labels:
    source:php.cn
    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template