How to set the background using the CSS background property
To set the background for an HTML element, in CSS there is a special property - background . This is a shorthand for many of the properties that control the appearance of an element. The values can be specified in any order, the browser is able to independently determine which of them corresponds to the desired property.
Among the many properties for setting the background, the following are usually distinguished:
- background-attachment - Sets whether the background image scrolls along with the content of the element. Possible values: fixed, scroll, inherit, local ;
- background-clip - Determines how the background image or background color will be displayed below the borders. Possible values: padding-box, border-box, content-box ;
- background-color - serves to define the background color of an element. Possible values: transparent, inherit ;
- background-image - sets the background image for the element. Possible values: url, none, inherit ;
- background-origin - defines the positioning area of the background image. Values: padding-box, border-box, content-box ;
- background-position - sets the initial position of the background image set using the corresponding property. Values: inherit and also px, em , etc .;
- background-position-x - sets the horizontal position of the background image inside the element, is a non-standard property and is not part of the specification. Values: inherit, left, center, right and px, em , etc .;
- background-position-y - sets the vertical position of the background image inside the element, is a non-standard property and is not part of the specification. Values: inherit, top, center, bottom and px, em , etc .;
- background-repeat - defines how the background image set using the corresponding property will be repeated. Values: no-repeat, repeat, repeat-x, repeat-y, inherit, space, round ;
- background-size - sets the scale of the background image according to the specified dimensions. Values: auto, cover, contain and %, px, em , etc.
Thus, the universal property background contains many properties that can be written individually or at one time in the background property.
Comments (0)
For commenting sign in or register.
Latest articles
- 09.07.22IT / Misc Convert office files DOC, DOCX, DOCM, RTF to DOCX, DOCM, DOC, RTF, PDF, HTML, XML, TXT formats without loss and markup changes
- 07.07.22IT / Safety How to protect PHP, JS, HTML, CSS source code - obfuscation, minification, compression and encryption
- 06.07.22IT / Safety Connection not secure, problem with Lets Encrypt - how to fix expired 09/30/2021 DST Root CA X3, remove it manually and install ISRG Root X1. Example on MS Windows 7
- 08.07.21IT / Misc How to make a free translation for a website without an API, translate documents in Google Translate
- 06.07.21IT / Misc How to make a subscription button on a website, a subscriber base and automatic mailing