當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


CSS color-adjust屬性用法及代碼示例

Color-adjust屬性已證明對打印文檔很有用。瀏覽器可以更改元素的顏色和外觀,以防止使用color-adjust屬性。

用法:

color-adjust:economy | exact

屬性值:

  • economy:在這種情況下,瀏覽器可能會留下圖像,以便調整文本的顏色,使其更具可讀性。

用法:

color-adjust:economy

例:



<!DOCTYPE html> 
<html lang="en"> 
<head> 
  <meta charset="UTF-8"> 
  <meta name="viewport" 
        content="width=device-width,  
                 initial-scale=1.0"> 
  <title>Document</title> 
</head> 
<style> 
  #box{ 
  width:300px; 
  height:auto; 
  border-radius:50% 50%; 
  background-color:black; 
  background-image:linear-gradient( 
rgba(17, 199, 0, 0.5), rgb(255, 255, 255)); 
  color:rgb(0, 0, 0); 
  text-align:center; 
  font:24px "Helvetica", sans-serif; 
  display:grid; 
  justify-content:center; 
  color-adjust:economy; 
} 
</style> 
<body> 
  <h1>color-adjust:economy</h1> 
  <div id="box"> 
    <p>Geeks for Geeks</p> 
  </div> 
</body> 
</html>

輸出:

  • exact:在這種情況下,未經用戶請求,不得更改頁麵的外觀。

用法:

color-adjust:exact

例:

<!DOCTYPE html> 
<html lang="en"> 
<head> 
  <meta charset="UTF-8"> 
  <meta name="viewport" 
        content="width=device-width, 
                 initial-scale=1.0"> 
  <title>Document</title> 
</head> 
<style> 
  #box{ 
  width:300px; 
  height:auto; 
  border-radius:50% 50%; 
  background-color:black; 
  background-image:linear-gradient( 
rgba(17, 199, 0, 0.5), rgb(255, 255, 255)); 
  color:#fff; 
  text-align:center; 
  font:24px "Helvetica", sans-serif; 
  display:grid; 
  justify-content:center; 
  color-adjust:exact; 
} 
</style> 
<body> 
  <h1>color-adjust:exact</h1> 
  <div id="box"> 
    <p>Geeks for Geeks</p> 
  </div> 
</body> 
</html>

輸出:

支持的瀏覽器:

  • Firefox
  • Opera
  • 火狐瀏覽器
  • Safari
  • Edge

相關用法


注:本文由純淨天空篩選整理自tarun007大神的英文原創作品 CSS color-adjust Property。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。