w3pop.com :: ÍøÂçѧԺ :: CSS :: CSS ±³¾°
The CSS background properties define the background effects of an element.
CSSµÄbackgroundÊôÐÔ¿ÉÎªÔªËØ¶¨Òå±³¾°Ð§¹û¡£
Set the background color
This example demonstrates how to set the background color for an element.
ÔõÑùÎªÔªËØÉèÖñ³¾°ÑÕÉ«
Set an image as the background
This example demonstrates how to set an image as the background
½«Í¼Æ¬ÉèÖÃΪ±³¾°
How to repeat a background image
This example demonstrates how to repeat a background image.
ÈçºÎÖØ¸´±³¾°Í¼Æ¬
How to repeat a background image only vertically
This example demonstrates how to repeat a background image only vertically.
ÈçºÎÈñ³¾°Í¼Æ¬´¹Ö±Öظ´
How to repeat a background image only horizontally
This example demonstrates how to repeat a background image only horizontally.
ÈçºÎÈñ³¾°Í¼Æ¬Ë®Æ½Öظ´
How to place the background image
This example demonstrates how to place the image on the page.
ÈçºÎ½«Í¼Æ¬·ÅÔÚÒ³ÃæÉÏ
How to set a fixed background image
This example demonstrates how to set a fixed background image. The image will not scroll with the rest of the page.
ÔõÑùÈñ³¾°Í¼Æ¬¹Ì¶¨ÔÚ±³¾°ÉÏ£¬²»¸úËæÒ³ÃæÒ»ÆðÒÆ¶¯
All the background properties in one declaration
This example demonstrates how to use the shorthand property for setting all of the background properties in one declaration.
ÔõÑùʹÓÃÒ»¾äÉùÃ÷¾ÍÄÜÉèÖÃËùÓÐÓëbackgroundÊôÐÔÓйصÄÖµ
The CSS background properties allow you to control the background color of an element, set an image as the background, repeat a background image vertically or horizontally, and position an image on a page.
CSS±³¾°ÊôÐÔÔÊÐíÄã¿ØÖÆÔªËØµÄ±³¾°ÑÕÉ«£¬ÉèÖÃһͼƬ×öΪ±³¾°£¬´¹Ö±»òˮƽµÄÖØ¸´±³¾°Í¼Æ¬£¬ºÍͼƬÔÚÒ³ÃæÉϵÄλÖá£
Browser support: IE: Internet Explorer, F: Firefox, N: Netscape.
ä¯ÀÀÆ÷Ö§³Ö£º IE: Internet Explorer, F: Firefox, N: Netscape.
W3C: The number in the "W3C" column indicates in which CSS recommendation the property is defined (CSS1 or CSS2).
ÔÚW3CÖеÄÊý×Ö´ú±íCSSµÄ°æ±¾£¨CSS1»òCSS2£©
| PropertyÊôÐÔ | DescriptionÃèÊö | ValuesÖµ | IE | F | N | W3C |
|---|---|---|---|---|---|---|
| background | A shorthand property for setting all background properties in one declaration Ò»¸öËÙ¼ÇÊôÐÔÀ´ÓÃÒ»¸öÉùÃ÷ÉèÖÃËùÓб³¾°ÊôÐÔ |
background-color background-image background-repeat background-attachment background-position |
4 | 1 | 6 | 1 |
| background-attachment | Sets whether a background image is fixed or scrolls with the rest of the page ÉèÖñ³¾°Í¼Æ¬Îª¹Ì¶¨»¹ÊǹöÆÁµÄ |
scroll fixed |
4 | 1 | 6 | 1 |
| background-color | Sets the background color of an element ÎªÒ»ÔªËØÉèÖñ³¾°ÑÕÉ« |
color-rgb color-hex color-name transparent |
4 | 1 | 4 | 1 |
| background-image | Sets an image as the background ÉèÖÃһͼƬ×öΪ±³¾° |
url none |
4 | 1 | 4 | 1 |
| background-position | Sets the starting position of a background image ÉèÖñ³¾°Í¼Æ¬µÄÆðʼλÖà |
top left top center top right center left center center center right bottom left bottom center bottom right x-% y-% x-pos y-pos |
4 | 1 | 6 | 1 |
| background-repeat | Sets if/how a background image will be repeated Èç¹û±³¾°ÓÐÖØ¸´Í¼Æ¬µÄ»°¾ÍÓÃÕâ¸öÉèÖà |
repeat repeat-x repeat-y no-repeat |
4 | 1 | 4 | 1 |