1. CSS background tag1. Set the background color The background-ground-color property specifies the background color of an element. The results are as follows: You can use selectors to set different colors for different tags. Here, the h1, div, and p tags will have different background colors: The running results are shown in the figure below: 2. Set the background image The background-image property specifies an image to use as the background of an element. By default, the image repeats to cover the entire element. Use URL to import external images. The running results are as follows: Note: When using background images, pay attention to the style of the background image and avoid images that interfere with the text, so as not to affect the effect. Problem with css background-repeat By default, the background-repeat property repeats the image both vertically and horizontally. Some images should only be repeated horizontally or vertically. If you want to repeat only horizontally, you need to use (background-repeat: repeat-x;), then the background will look better. If you want to repeat the image only vertically, you need to set background-repeat: repeat-y. 4. Specify the location of the background image To specify the position of the background image, you need to use the background-position tag. The specific example is shown in the figure below: The running results are shown in the figure below: 5. Set the background image to be fixed The background-attachment property is used to set the background image to be fixed. The property value scroll means the image scrolls with the page elements (the default value), and fixed means the image is fixed on the screen and does not scroll with the page elements. 6. Set the background image size The background-size property can set the height and width of the background image. The first value sets the width and the second sets the height. If you set a value, the second value will default to auto. Its format is as follows: The results are as follows: 7. Set image transparency effect The opacity attribute can be used to make any element transparent. The transparency is between 0 and 1. The format is as follows: 2. CSS border tag1. Set the border color (1) Set the border style (border-style) This is the end of this article summarizing CSS background and border tags. For more relevant CSS background and border content, please search 123WORDPRESS.COM’s previous articles or continue to browse the related articles below. I hope everyone will support 123WORDPRESS.COM in the future! |
>>: Two ways to specify the character set of the html page
Table of contents introduction Why bother? Commun...
There are two situations 1. Start time and end ti...
This article introduces blue-green deployment and...
1. I downloaded QT5.13 version before, but after ...
Table of contents 1. Self-enumerable properties 2...
Similar to the code hosting service provided by G...
Problem Description By configuring nginx, you can...
1. Indexes do not store null values More precisel...
Create your first web page in one minute: Let'...
Data integrity is divided into: entity integrity,...
Table of contents 1. RegExp object 2. Grammar 2.1...
For commercial databases, database upgrade is a h...
React is a JAVASCRIPT library for building user i...
background Today, while cooperating with other pr...