backgroundThe background attribute is an important attribute in CSS. You can use the background attribute to set various styles of a background element, including setting the color of the filled background, using your own picture as the background, so that the picture will repeat horizontally and vertically until it covers the entire element, and controlling the position of the background picture in the element. etc. Using pictures as backgrounds is often encountered in a web page layout. Generally, setting the object picture as the background attribute instance first sets the background color, followed by setting the picture as the background, followed by whether the picture is repeated, and then the picture at the object position. The previous background color does not need to be set and is not required. Generally, a picture is used as the object background. If you want to set whether the picture is displayed repeatedly, the distance position will be set. The following content will specifically explain the various uses of the background background attribute.
First of all, you can learn free courses related to php Chinese website
1. Learn"CSS 0 Basic Introductory Tutorial" in CSS Background Chapter Course
##2. Watch the Background and Margin video course in "Dark Horse Programmer CSS Video Tutorial"
background background property1.
CSS knowledge that must be mastered-background propertyWhen we set the border for the body, we will find that the border only encloses the content in the body. But setting the background color for the body fills the entire screen.
When using an image as the background, the image is positioned with reference to the visible area of the screen, not the part framed by the border.
Each parameter is separated by spaces, followed by color, picture, repetition, fixation method, and position.
2.
Background related attributes in cssPercent/length: If it is a percentage, the size of the background image is the product of the container times the percentage. Set only one, and set the second one to auto (to maintain the same aspect ratio as the original background image).
If both are set to 100%, the background image will fill the container, but the aspect ratio will change.
contain: The container contains the entire background image according to a fixed proportion of the background image. The size of the background image is enlarged by a fixed ratio based on the background image. Until any side reaches the boundary of the container, the other side will often be blank (when there is no-repeat).
cover: The background image is enlarged according to a fixed aspect ratio until it fills the entire container (the shorter side of the background image also reaches the container boundary). Part of the background image will be cut off because it exceeds the container.
3.
Detailed explanation of the background attribute of cssIn the same element, the background composite attribute is written at the front, and the background attribute that needs to be set individually is written at the end; reason : The front wave of the Yangtze River pushes back the wave, and the front wave dies on the beach.
Multiple background images are added to the same element. Other background attributes can only be written separately, and composite attribute abbreviations cannot be used;
in In nested parent-child elements, it is not recommended to write attributes with the same name. Reason: When the size of the child element is greater than or equal to the size of the parent element, the style of the parent element will be overwritten by the child element;
In actual work, use more background images and less use of inserted pictures.
4.
Detailed explanation of the new background series background in CSS3border-box: Ignore the border and start tiling directly from the starting point 0,0 of the border padding-box: Default value, ignore padding, and start tiling directly from the starting point 0,0 of padding. content-box: start tiling from the content part, and the padding position will be reserved. So padding will affect it
5. How to set the css background image and background color in the web page
CSS background here refers to setting the background properties of the object through CSS, such as setting the background through CSS in the web page. style.
Css background Background function: Set a solid color background. Background background can set the background color of the object to a solid color and set the image as the background. You can set the background of the object to a picture. If the background is a picture, you can make the picture tile repeatedly or horizontally, or fix the picture as the background of the object at any position of the object.
6. Summary sharing of CSS background attributes and CSS3 background image settings
background Set all background attributes in one statement
background- attachment Sets whether the background image is fixed or scrolls with the rest of the page
background-color Sets the background color of the element
background-image Sets the background image of the element
background- position Set the starting position of the background image
Related questions and answers
1. How to speed up the loading speed of css background images
2. Can’t background:unset be used on ios? So what do you do if you want to cancel the background color?
[Related recommendations]
1. PHP Chinese website free tutorial: 《CSS Online Manual》
2. PHP Chinese website free video tutorial: 《Learn HTML video tutorial at your fingertips》
3. PHP Chinese website free video tutorial: 《php.cn Dugu Jiujian (2)-css video tutorial》
The above is the detailed content of Summary of the use of background attributes in css. For more information, please follow other related articles on the PHP Chinese website!

在css中,可用list-style-type属性来去掉ul的圆点标记,语法为“ul{list-style-type:none}”;list-style-type属性可设置列表项标记的类型,当值为“none”可不定义标记,也可去除已有标记。

区别是:css是层叠样式表单,是将样式信息与网页内容分离的一种标记语言,主要用来设计网页的样式,还可以对网页各元素进行格式化;xml是可扩展标记语言,是一种数据存储语言,用于使用简单的标记描述数据,将文档分成许多部件并对这些部件加以标识。

在css中,可以利用cursor属性实现鼠标隐藏效果,该属性用于定义鼠标指针放在一个元素边界范围内时所用的光标形状,当属性值设置为none时,就可以实现鼠标隐藏效果,语法为“元素{cursor:none}”。

在css中,rtl是“right-to-left”的缩写,是从右往左的意思,指的是内联内容从右往左依次排布,是direction属性的一个属性值;该属性规定了文本的方向和书写方向,语法为“元素{direction:rtl}”。

转换方法:1、给英文元素添加“text-transform: uppercase;”样式,可将所有的英文字母都变成大写;2、给英文元素添加“text-transform:capitalize;”样式,可将英文文本中每个单词的首字母变为大写。

在css中,可以利用“font-style”属性设置i元素不是斜体样式,该属性用于指定文本的字体样式,当属性值设置为“normal”时,会显示元素的标准字体样式,语法为“i元素{font-style:normal}”。

在css3中,可以用“transform-origin”属性设置rotate的旋转中心点,该属性可更改转换元素的位置,第一个参数设置x轴的旋转位置,第二个参数设置y轴旋转位置,语法为“transform-origin:x轴位置 y轴位置”。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver Mac version
Visual web development tools

Notepad++7.3.1
Easy-to-use and free code editor

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Mac version
God-level code editing software (SublimeText3)
