search
HomeWeb Front-endCSS TutorialQuickly understand the CSS4 color-adjust property in 5 minutes


#This article brings you a quick understanding of the CSS4 color-adjust property in 5 minutes. It has certain reference value for friends in need. You can refer to it, I hope it will be helpful to you.

1. Brief description of the color-adjust attribute

color-adjust was originally a non-standard attribute, but it has recently been added to the working draft of CSS Color Module Level 4, which is considered useful. Now that I have a good reputation, it deserves an introduction.

The function of the color-adjust CSS attribute can be expressed in one sentence: whether to allow the browser to adjust the color by itself for a better reading experience.

Syntax

color-adjust: economy;
color-adjust: exact;

Where:

economy

Default value. The literal translation of economy in English means "economy" and "saving". This means that the browser (or other client) adjusts the style of the element, and the adjustment rules are determined by the browser itself to avoid achieving better output effects. For example, when printing, the browser will choose to omit all background images and adjust text color to ensure contrast is optimal for reading on white paper.

It is now 2018. Modern devices other than printers have very powerful monitors. It seems that we cannot encounter this kind of "saving background color" and "saving color value" scenarios; but this is not the case. For example, macOS has In addition to the cool night vision mode, this is a scene that requires increased contrast, and the device should be given the ability to freely adjust the style performance. In the future, there will be other devices with other reading scenarios. From a future-oriented perspective, the color-adjust attribute has its value.

exact

exact means "accurate" and "accurate". It means telling the browser that the colors, backgrounds, etc. I set are necessary and match accurately. Don't be smart and help me make adjustments.

For example, in order to facilitate reading, we will add gray and white detailed striped zebra crossings to the table. However, if we print this page at this time, the gray background will be removed, which will affect the reading experience. At this time, we You can set the gray stripe zebra color to be "accurate" so that the gray stripes print normally.

Compatibility

The following screenshot:

Quickly understand the CSS4 color-adjust property in 5 minutes

Both Chrome and Firefox support it, Chrome needs to add the -webkit-private prefix. However, according to my testing, what Chrome does not support is actually the -webkit-print-color-adjust attribute, which can be regarded as the predecessor of color-adjust before it had a name.

-webkit-print-color-adjust and color-adjust attribute values ​​and functions are the same.

2. A case of color-adjust

You can click here: the background color is still displayed when printing, contrast demo

Ctrl P Or select the "Print" menu of the browser. At this time, you can see the difference:

Quickly understand the CSS4 color-adjust property in 5 minutes

#The reason why the following table is displayed as striped when printing preview is because of the setting The following CSS is added:

table {
-webkit-print-color-adjust: exact;
color-adjust: exact;
}

There is a similar behavior under the Firefox browser:

Quickly understand the CSS4 color-adjust property in 5 minutes

Three or five minutes are up

Finally, briefly comment on the color-adjust attribute.

It’s difficult to reach the level of elegance, non-appearance-related CSS. Not learning or listening will have little impact on our daily work. It is estimated that even if I work for another 10 years, it will be difficult to encounter scenes that require the use of the color-adjust attribute.

Just like those unpopular and niche movies, although they have their artistic quality and value, for us, they are not a must.

Fortunately, it only took 5 minutes. In addition, the knowledge itself is useful. You may not be able to deal with some special equipment or special scenes in the future. At this time, color-adjust is a life-saving attribute. Therefore, the cost-effectiveness of learning is actually very good. If you understand it, learn it.

The above is a quick introduction to the CSS4 color-adjust property in 5 minutes. If you want to know more about CSS3 tutorial, please pay attention to the PHP Chinese website.



The above is the detailed content of Quickly understand the CSS4 color-adjust property in 5 minutes. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:zhangxinxu. If there is any infringement, please contact admin@php.cn delete
Demystifying Screen Readers: Accessible Forms & Best PracticesDemystifying Screen Readers: Accessible Forms & Best PracticesMar 08, 2025 am 09:45 AM

This is the 3rd post in a small series we did on form accessibility. If you missed the second post, check out "Managing User Focus with :focus-visible". In

Adding Box Shadows to WordPress Blocks and ElementsAdding Box Shadows to WordPress Blocks and ElementsMar 09, 2025 pm 12:53 PM

The CSS box-shadow and outline properties gained theme.json support in WordPress 6.1. Let's look at a few examples of how it works in real themes, and what options we have to apply these styles to WordPress blocks and elements.

Making Your First Custom Svelte TransitionMaking Your First Custom Svelte TransitionMar 15, 2025 am 11:08 AM

The Svelte transition API provides a way to animate components when they enter or leave the document, including custom Svelte transitions.

Working With GraphQL CachingWorking With GraphQL CachingMar 19, 2025 am 09:36 AM

If you’ve recently started working with GraphQL, or reviewed its pros and cons, you’ve no doubt heard things like “GraphQL doesn’t support caching” or

Classy and Cool Custom CSS Scrollbars: A ShowcaseClassy and Cool Custom CSS Scrollbars: A ShowcaseMar 10, 2025 am 11:37 AM

In this article we will be diving into the world of scrollbars. I know, it doesn’t sound too glamorous, but trust me, a well-designed page goes hand-in-hand

Show, Don't TellShow, Don't TellMar 16, 2025 am 11:49 AM

How much time do you spend designing the content presentation for your websites? When you write a new blog post or create a new page, are you thinking about

Building an Ethereum app using Redwood.js and FaunaBuilding an Ethereum app using Redwood.js and FaunaMar 28, 2025 am 09:18 AM

With the recent climb of Bitcoin’s price over 20k $USD, and to it recently breaking 30k, I thought it’s worth taking a deep dive back into creating Ethereum

What the Heck Are npm Commands?What the Heck Are npm Commands?Mar 15, 2025 am 11:36 AM

npm commands run various tasks for you, either as a one-off or a continuously running process for things like starting a server or compiling code.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Safe Exam Browser

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.