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
Preface Whether it is a stand-alone lock or a dis...
Sublime Sublime Text is a code editor (Sublime Te...
Table of contents Global Object Global objects an...
Preface When I was working on a project recently,...
First go to the official website to download and ...
This article introduces how to install the system...
Text truncation with CSS Consider the following c...
The complete syntax of the SELECT statement is: (...
Preface Before leaving get off work, the author r...
Introduction Part 1: Written at the beginning One...
Suppose Taobao encourages people to shop during D...
Why mention textarea specifically? Because the tex...
Table of contents Preface Environment Preparation...
Preface What is data type conversion? The default...
1. On a networked machine, use the default centos...