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 View Disk Usage Disk Cleanup (D...
Table of contents 1. Some concepts of Tomcat –1, ...
Table of contents The CSS custom variable functio...
I installed MySQL smoothly in Ubuntu 16.04 before...
Table of contents background analyze Data simulat...
Table of contents Symbol Data Type The reason why...
If you are not committed to becoming an artist, t...
Table of contents 01 Container consistency 02 Con...
1. How do I remove the blank space of a few pixels...
This time let’s look at a navigation bar layout w...
This article example shares the specific code of ...
1. Purchase a server In the example, the server p...
Table of contents Achieve results Complete code +...
Before further analyzing why MySQL database index...
Table of contents Preface condition Install Docke...