Home>Article>Web Front-end> How to set image background with css
How to set the image background in css: 1. Use the background-image attribute, the syntax "background-image:url('image address');"; 2. Use the background attribute, the syntax "background:url(' The map's address');".
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
In css, you can use the background-image attribute or background attribute to set the image background.
css background-image property
The background-image property sets the background image of an element.
The background of an element is the total size of the element, including padding and borders (but not margins).
By default, the background-image is placed in the upper left corner of the element and repeats vertically and horizontally.
Attribute value:
url('URL') Path pointing to the image.
none Default value. No background image is displayed.
inherit specifies that the setting of the background-image property should be inherited from the parent element.
Example:
css设置背景图片
Rendering:
##css background attribute
The background attribute is a property specifically set for the background. It is a shorthand property that can set all background properties in one statement. (Learning video sharing:css video tutorial)
Background attributes that can be set:background-image:url(1.jpg);This is given in url() By specifying the path of the image, you can set a background image for the div box; it seems simple, but one thing to note is that the box for setting the background image must have substantial width and height, so that the background image can be displayed on the display.
background:url(bgimg.gif) no-repeat 5px 5px;Explanation as shown below: Example:
Rendering:背景图片设置
Introduction to Programming! !
The above is the detailed content of How to set image background with css. For more information, please follow other related articles on the PHP Chinese website!