color-adjust CSS property sets what, if anything, the 用户代理 may do to optimize the appearance of the element on the output device. By default, the browser is allowed to make any adjustments to the element's appearance it determines to be necessary and prudent given the type and capabilities of the output device.

句法

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

color-adjust property's value must be one of the following keywords.

economy

The user agent is allowed to make adjustments to the element as it deems appropriate and prudent in order to optimize the output for the device it's being rendered for. For example, when printing, a browser might opt to leave out all background images and to adjust text colors to be sure the contrast is optimized for reading on white paper. This is the default.

exact

The element's content has been specifically and carefully crafted to use colors, images, and styles in a thoughtful and/or important way, such that being altered by the browser might actually make things worse rather than better. The appearance of the content should not be changed except by the user's request. For example, a page might include a list of information with rows whose background colors alternate between white and a light grey. Removing the background color would decrease the legibility of the content.

用法注意事项

There are a number of reasons a browser might wish to deviate from the specified appearance, such as:

  • The content uses text and background colors that will be too similar on the output device for legibility purposes.
  • If the output device is a printer, and to save ink, dark or extremely dense background images might be removed.
  • When printing a page, the browser might want to replace light-colored text on a dark background with dark text on a white background.

Any options the user agent offers the user to allow them to control the use of color and images will take priority over the value of color-adjust . In other words, there isn't any guarantee that color-adjust will do anything. Not only can the user override the behavior, but each user agent is allowed to decide for itself how to handle color-adjust in any given situation.

形式定义

初始值 economy
适用于 所有元素
继承 yes
计算值 如指定
动画类型 discrete

形式句法

economy | exact
					

范例

Preserving low contrast

In this example, a box is shown which uses a background-image and a translucent linear-gradient() function atop a black background color to have a dark blue gradient behind medium red text. For whatever reason, this is the desired appearance in any rendering environment, including on paper, so we also use color-adjust: exact to tell the browser not to make color or style adjustments to the box when rendering it.

CSS

.my-box {
  background-color: black;
  background-image: linear-gradient(rgba(0, 0, 180, 0.5), rgba(70, 140, 220, 0.5));
  color: #900;
  width: 15rem;
  height: 6rem;
  text-align: center;
  font: 24px "Helvetica", sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  color-adjust: exact;
}
					

HTML

<div class="my-box">
  <p>Need more contrast!</p>
</div>
					

结果

规范

规范 状态 注释
CSS Color Adjustment Module Level 1
The definition of 'color-adjust' in that specification.
编者草案 初始定义。

浏览器兼容性

The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
color-adjust Chrome 完整支持 49 Alternate Name
完整支持 49 Alternate Name
Alternate Name Uses the non-standard name: -webkit-print-color-adjust
Edge 完整支持 79 Alternate Name
完整支持 79 Alternate Name
Alternate Name Uses the non-standard name: -webkit-print-color-adjust
Firefox 完整支持 48 IE 不支持 No Opera 完整支持 15 Alternate Name
完整支持 15 Alternate Name
Alternate Name Uses the non-standard name: -webkit-print-color-adjust
Safari 完整支持 6 Alternate Name
完整支持 6 Alternate Name
Alternate Name Uses the non-standard name: -webkit-print-color-adjust
WebView Android 完整支持 49 Alternate Name
完整支持 49 Alternate Name
Alternate Name Uses the non-standard name: -webkit-print-color-adjust
Chrome Android 完整支持 49 Alternate Name
完整支持 49 Alternate Name
Alternate Name Uses the non-standard name: -webkit-print-color-adjust
Firefox Android 完整支持 48 Opera Android 完整支持 36 Alternate Name
完整支持 36 Alternate Name
Alternate Name Uses the non-standard name: -webkit-print-color-adjust
Safari iOS 完整支持 6 Alternate Name
完整支持 6 Alternate Name
Alternate Name Uses the non-standard name: -webkit-print-color-adjust
Samsung Internet Android 完整支持 5.0 Alternate Name
完整支持 5.0 Alternate Name
Alternate Name Uses the non-standard name: -webkit-print-color-adjust

图例

完整支持

完整支持

不支持

不支持

使用非标名称。

使用非标名称。

另请参阅

元数据

  • 最后修改:
  1. CSS
  2. CSS 参考
  3. CSS Color
  4. 特性
    1. color
    2. color-adjust
    3. opacity

Copyright  © 2014-2026 乐数软件    

工业和信息化部: 粤ICP备14079481号-1