
- CSS 教程
- CSS - 首頁
- CSS - 路線圖
- CSS - 簡介
- CSS - 語法
- CSS - 選擇器
- CSS - 包含
- CSS - 測量單位
- CSS - 顏色
- CSS - 背景
- CSS - 字型
- CSS - 文字
- CSS - 圖片
- CSS - 連結
- CSS - 表格
- CSS - 邊框
- CSS - 塊級邊框
- CSS - 內聯邊框
- CSS - 外邊距
- CSS - 列表
- CSS - 內邊距
- CSS - 游標
- CSS - 輪廓
- CSS - 尺寸
- CSS - 捲軸
- CSS - 塊內元素
- CSS - 下拉選單
- CSS - 可見性
- CSS - 溢位
- CSS - 清除浮動
- CSS - 浮動
- CSS - 箭頭
- CSS - 調整大小
- CSS - 引號
- CSS - 順序
- CSS - 定位
- CSS - 連字元
- CSS - 懸停
- CSS - 顯示
- CSS - 聚焦
- CSS - 縮放
- CSS - 平移
- CSS - 高度
- CSS - 連字元字元
- CSS - 寬度
- CSS - 不透明度
- CSS - z-index
- CSS - 底部
- CSS - 導航欄
- CSS - 覆蓋層
- CSS - 表單
- CSS - 對齊
- CSS - 圖示
- CSS - 圖片庫
- CSS - 註釋
- CSS - 載入器
- CSS - 屬性選擇器
- CSS - 組合器
- CSS - 根元素
- CSS - 盒模型
- CSS - 計數器
- CSS - 剪裁
- CSS - 書寫模式
- CSS - Unicode-bidi
- CSS - min-content
- CSS - all
- CSS - inset
- CSS - isolation
- CSS - overscroll
- CSS - justify-items
- CSS - justify-self
- CSS - tab-size
- CSS - pointer-events
- CSS - place-content
- CSS - place-items
- CSS - place-self
- CSS - max-block-size
- CSS - min-block-size
- CSS - mix-blend-mode
- CSS - max-inline-size
- CSS - min-inline-size
- CSS - offset
- CSS - accent-color
- CSS - user-select
- CSS 高階
- CSS - 網格
- CSS - 網格佈局
- CSS - Flexbox
- CSS - 可見性
- CSS - 定位
- CSS - 層
- CSS - 偽類
- CSS - 偽元素
- CSS - @規則
- CSS - 文字效果
- CSS - 分頁媒體
- CSS - 列印
- CSS - 佈局
- CSS - 驗證
- CSS - 圖片精靈
- CSS - !important
- CSS - 資料型別
- CSS3 教程
- CSS3 - 教程
- CSS - 圓角
- CSS - 邊框圖片
- CSS - 多背景
- CSS - 顏色
- CSS - 漸變
- CSS - 盒陰影
- CSS - 盒裝飾中斷
- CSS - 游標顏色
- CSS - 文字陰影
- CSS - 文字
- CSS - 2D 變換
- CSS - 3D 變換
- CSS - 過渡
- CSS - 動畫
- CSS - 多列
- CSS - 盒尺寸
- CSS - 工具提示
- CSS - 按鈕
- CSS - 分頁
- CSS - 變數
- CSS - 媒體查詢
- CSS - 函式
- CSS - 數學函式
- CSS - 遮罩
- CSS - 形狀
- CSS - 樣式圖片
- CSS - 特異性
- CSS - 自定義屬性
- CSS 響應式
- CSS 響應式 - 簡介
- CSS 響應式 - 視口
- CSS 響應式 - 網格檢視
- CSS 響應式 - 媒體查詢
- CSS 響應式 - 圖片
- CSS 響應式 - 影片
- CSS 響應式 - 框架
- CSS 工具
- CSS - PX 到 EM 轉換器
- CSS - 顏色選擇器和動畫
- CSS 資源
- CSS - 有用資源
- CSS - 討論
CSS - 游標顏色屬性
CSS caret-color 屬性指定游標的顏色,游標是可見的標記,也稱為文字輸入游標。它用於使用游標且可編輯的輸入元素,例如輸入表單、文字框、textarea 等。
語法
caret-color: auto | color | transparent | initial | inherit;
屬性值
值 | 描述 |
---|---|
auto | 瀏覽器使用 currentColor 來表示游標。預設值。 |
color | 可以使用不同的格式(顏色名稱、十六進位制、rgb 等)指定游標的顏色。 |
transparent | 游標不可見。 |
initial | 將屬性設定為其預設值。 |
inherit | 從父元素繼承屬性。 |
CSS 游標顏色屬性示例
以下示例說明了使用不同值的 caret-color 屬性。
使用 auto 值的游標顏色屬性
要讓瀏覽器決定使用當前文字顏色來決定游標的顏色,我們使用 auto 值。當前文字顏色將應用於游標。這在以下示例中顯示。
示例
<!DOCTYPE html> <html> <head> <style> div { display: grid; gap: 20px; width: 60%; } .inp { border: 2px solid black; font-size: 16px; padding: 5px; caret-color: auto; } .text { color: blue; } .textarea { color: red; } </style> </head> <body> <h2> CSS caret-color property </h2> <div> <label> caret-color: auto (color of the text will be applied to caret) </label> <input type="text" value="Default cursor color." class=" inp text" /> <textarea rows="10" class=" inp textarea">Default caret color. </textarea> </div> </body> </html>
使用顏色值的游標顏色屬性
要為游標指定我們選擇的顏色,我們可以使用不同的格式(顏色名稱、十六進位制值、rgb 值、hsl 值等)指定顏色。指定的顏色將應用於游標。這在以下示例中顯示。
示例
<!DOCTYPE html> <html> <head> <style> div { display: grid; gap: 20px; width: 60%; } .inp { border: 2px solid black; font-size: 20px; padding: 5px; } .text1 { caret-color: orange; } .text2 { caret-color: #ff4d94; } .text3 { caret-color: rgb(0, 204, 204); } .textarea { caret-color: hsl(120, 100%, 50%); } </style> </head> <body> <h2> CSS caret-color property </h2> <div> <label> caret-color: color values (specified color will be applied to caret.) </label> <input type="text" value="Green caret color." class=" inp text1" /> <input type="text" value="Pink cursor color." class=" inp text2" /> <input type="text" value="Blue cursor color." class=" inp text3" /> <textarea rows="10" class=" inp textarea">green cursor color. </textarea> </div> </body> </html>
使用 transparent 值的游標顏色屬性
要使游標透明,使其不可見,我們使用 transparent 值。這在以下示例中顯示。
示例
<!DOCTYPE html> <html> <head> <style> div { display: grid; gap: 20px; width: 60%; } .inp { border: 2px solid black; font-size: 16px; padding: 5px; caret-color: transparent; } </style> </head> <body> <h2> CSS caret-color property </h2> <div> <label> caret-color: transparent (cursor color will not be visible) </label> <input type="text" value="transparent caret." class="inp" /> <textarea rows="10" class=" inp">transparent caret. </textarea> </div> </body> </html>
支援的瀏覽器
屬性 | ![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|---|
caret-color | 57.0 | 79.0 | 53.0 | 11.1 | 44.0 |
css_properties_reference.htm
廣告