


Excerpted from MDN. Due to time reasons, I couldn't organize my study properly. I will quote it first and then organize it in detail when I have time.
background-size sets the background image size.
/* 关键字 */background-size: coverbackground-size: contain/* 一个值: 这个值指定图片的宽度,图片的高度隐式的为auto */background-size: 50%background-size: 3embackground-size: 12pxbackground-size: auto/* 两个值: 第一个值指定图片的宽度,第二个值指定图片的高度 */background-size: 50% autobackground-size: 3em 25%background-size: auto 6pxbackground-size: auto auto/* 逗号分隔的多个值:设置多重背景 */background-size: auto, auto /* 不同于background-size: auto auto */background-size: 50%, 25%, 25%background-size: 6px, auto, containbackground-size: inherit
Values
Bitmaps must have inherent dimensions and proportions, while vector images may have both or only one. Gradient is treated as an image with only intrinsic dimensions or only intrinsic proportions.
Background image size calculation:
If two values of background-size are specified and it is not auto: the background image is rendered at the specified size. contain or cover: retain the inherent proportions and maximize the inclusion or coverage of the background area. If the image has no inherent proportions, it is sized according to the background area. auto or auto auto: If the image has two lengths, use this size. If there is no inherent size or proportion, the size of the background area is used. If there is no intrinsic size but an intrinsic proportion, the effect is the same as contain. If there is a length and ratio, the size is calculated from this length and ratio. If there is a length but no scale, then the length corresponding to the background area is used. One is auto and the other is not auto: If the image has intrinsic proportions, the specified length uses the specified value, and the unspecified length is calculated from the specified value and the intrinsic proportion. If the image does not have an intrinsic proportion, the specified length uses the specified value, and the unspecified length uses the corresponding intrinsic length of the image. If there is no intrinsic length, the corresponding length of the background area is used.Note that not all browsers support vector graphics that do not have inherent dimensions or proportions. Pay special attention to testing Firefox 7- vs. Firefox 8 to determine whether the differences are acceptable.
Examples
background-size: cover demo and background-size: contain demo opens in a new window, so you can see when the size of the background area changes, contain and What does cover look like? A series of demonstrations: background-size and its association with the background-* attributes illustrates the use of background-size alone and in conjunction with other attributes.
Notes
If you use a gradient as the background and use background-size on it, it is best not to use only one auto, or only specify a width value (for example, background-size: 50%) . Firefox 8 has changed in these two situations, and the current performance of each browser is inconsistent. Not all browsers fully support the CSS3 background-size specification and the CSS3 Image Values gradient specification.
.bar { width: 50px; height: 100px; background-image: gradient(...); /* 不推荐 */ background-size: 25px; background-size: 50%; background-size: auto 50px; background-size: auto 50%; /* 可行 */ background-size: 25px 50px; background-size: 50% 50%;}
It is especially not recommended to use gradient px with auto, because it cannot be re-rendered before Firefox 8, and for browsers that do not implement Firefox 8 rendering features, I don’t know how to specify it. The exact size of the background's elements.
Only supported by IE9 and above.

The role of HTML is to define the structure and content of a web page through tags and attributes. 1. HTML organizes content through tags such as , making it easy to read and understand. 2. Use semantic tags such as, etc. to enhance accessibility and SEO. 3. Optimizing HTML code can improve web page loading speed and user experience.

HTMLisaspecifictypeofcodefocusedonstructuringwebcontent,while"code"broadlyincludeslanguageslikeJavaScriptandPythonforfunctionality.1)HTMLdefineswebpagestructureusingtags.2)"Code"encompassesawiderrangeoflanguagesforlogicandinteract

HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

How to design the dotted line segmentation effect in the menu? When designing menus, it is usually not difficult to align left and right between the dish name and price, but how about the dotted line or point in the middle...

HTML Element Analysis in Web Code Editor Many online code editors allow users to enter HTML, CSS, and JavaScript code. Recently, someone proposed...


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

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

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

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

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.