- 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 - 全部
- CSS - 內嵌
- CSS - 隔離
- CSS - 滾動溢位
- CSS - Justify Items
- CSS - Justify Self
- CSS - Tab Size
- CSS - 指標事件
- CSS - Place Content
- CSS - Place Items
- CSS - Place Self
- CSS - 最大塊尺寸
- CSS - 最小塊尺寸
- CSS - 混合模式
- CSS - 最大內聯尺寸
- CSS - 最小內聯尺寸
- CSS - 偏移量
- CSS - 強調色
- CSS - 使用者選擇
- 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 - 二維變換
- CSS - 三維變換
- CSS - 過渡
- CSS - 動畫
- CSS - 多列
- CSS - 盒尺寸
- CSS - 工具提示
- CSS - 按鈕
- CSS - 分頁
- CSS - 變數
- CSS - 媒體查詢
- CSS - 函式
- CSS - 數學函式
- CSS - 遮罩
- CSS - 形狀
- CSS - 樣式圖片
- CSS - 特效性
- CSS - 自定義屬性
- CSS 響應式
- CSS RWD - 簡介
- CSS RWD - 視口
- CSS RWD - 網格檢視
- CSS RWD - 媒體查詢
- CSS RWD - 圖片
- CSS RWD - 影片
- CSS RWD - 框架
- CSS 工具
- CSS - PX 到 EM 轉換器
- CSS - 顏色選擇器和動畫
- CSS 資源
- CSS - 有用資源
- CSS - 討論
CSS 資料型別 - <custom-ident>
CSS 資料型別<custom-ident>表示自定義識別符號。它用於表示開發者為某些 CSS 屬性或值定義的自定義名稱或識別符號。此資料型別透過啟用超出預定義關鍵字和標準識別符號的自定義名稱的使用,從而允許更廣泛的可能性。
自定義識別符號通常用於開發者希望為樣式或主題的某些方面建立和使用自己的命名約定。
例如,在 CSS 變數(自定義屬性)的上下文中,您可以使用<custom-ident>來表示變數名稱的自定義識別符號。
:root {
--main-color: red;
}
.element {
color: var(--main-color);
}
在此示例中,--main-color 是一個自定義識別符號,var() 函式用於引用自定義屬性中儲存的值。
禁止的值
為避免不確定性,每個使用 <custom-ident> 的屬性都禁止使用下面列出的特定值。
animation-name − 禁止使用全域性 CSS 值(unset、initial、inherit 和 none)。
counter-reset, counter-increment − 禁止使用全域性 CSS 值(unset、initial、inherit 和 none)。
@counter-style, list-style-type − 禁止使用全域性 CSS 值(unset、initial、inherit),以及 (none, inline, outside),以及以下值:disc, circle, square, decimal, cjk-decimal, decimal-leading-zero, lower-roman, upper-roman, lower-greek, lower-alpha, lower-latin, upper-alpha, upper-latin, arabic-indic, armenian, bengali, cambodian, cjk-earthly-branch, cjk-heavenly-stem, cjk-ideographic, devanagari, ethiopic-numeric, georgian, gujarati, gurmukhi, hebrew, hiragana, hiragana-iroha, japanese-formal, japanese-informal, kannada, katakana, katakana-iroha, khmer, korean-hangul-formal, korean-hanja-formal, korean-hanja-informal, lao, lower-armenian, malayalam, mongolian, myanmar, oriya, persian, simp-chinese-formal, simp-chinese-informal, tamil, telugu, thai, tibetan, trad-chinese-formal, trad-chinese-informal, upper-armenian, disclosure-open, disclosure-close。
grid-row-start, grid-row-end, grid-column-start, grid-column-end − 禁止使用 span 值。
view-transition-name − 禁止使用全域性 CSS 值(unset、initial、inherit),以及 none。
will-change − 禁止使用全域性 CSS 值(unset、initial、inherit),以及 (will-change, auto, scroll-position, and contents) 值。
語法
CSS <custom-ident> 的語法遵循與 CSS 屬性名稱相同的規則,但它區分大小寫。此元素包含一個或多個字元,定義如下:
A 到 Z 或 a 到 z 之間的任何字母。
0 到 9 之間的任何十進位制數字。
連字元 (-) 字元。
下劃線 (_) 字元。
跳脫字元定義為反斜槓 (/) 後面的字元。
由反斜槓 (/) 後跟一個到六個十六進位制數字表示的 Unicode 字元。
跳脫字元
可以透過轉義來將 Unicode 程式碼點包含在<custom-ident> 或帶引號的<string> 中。
CSS 提供了各種跳脫字元的方法。轉義序列以反斜槓 (\) 開頭,後跟:
一到六位十六進位制序列 (ABCDEF0123456789) 可選擇後跟空格。這些序列將被替換為與指定十六進位制數字對應的 Unicode 程式碼點,空格允許後續的實際十六進位制數字。
任何既不是十六進位制數也不是換行符的 Unicode 程式碼點。
示例
"&B" 可以表示為 \26 B 或 \000026B。
"hi.there" 可以表示為 hi\.there 或 hi\002Ethere。
"toto?" 可以寫成 toto\?, toto\3F 或 toto\00003F。
有效識別符號
以下語法表示字母數字字元和數字的組合:
tata59 A combination of alphanumeric characters and numbers. high-level A combination of alphanumeric characters and a dash -nest Alphanumeric characters are placed after a dash. _external Alphanumeric characters are placed after a underscore. \11 nono A group of alphanumeric characters that follows a Unicode character. tili\.wow A correctly escaped period.
無效識別符號
以下語法表示表示值的特定規則:
24rem It must not begin with a decimal digit. -16rad It cannot begin with a dash followed by a decimal digit. tili.wow The only characters that don't require escape are alphanumeric characters, _, and -. 'tiliwow' This would be a <string>. "tiliwow" This would be a <string>.
CSS <custom-ident> - animation-name
以下示例演示了透過定義@Keyframes -demoanimation 來使用animation-name 屬性。連字元 (-) 命名約定作為自定義識別符號附加到 CSS 語法:
<html>
<head>
<style>
@keyframes -demoanimation {
0% {
transform: translateX(0);
}
50% {
transform: translateX(100px);
}
100% {
transform: translateX(0);
}
}
.box {
width: 100px;
height: 100px;
background-color: pink;
animation-name: -demoanimation;
animation-duration: 3s;
animation-iteration-count: infinite;
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</html>
CSS <custom-ident> - counter-reset, counter-increment
以下示例演示了使用自定義識別符號demo-counter 的counter-reset 屬性,並將它的初始值設定為 0。counter-increment 屬性每次都會遞增計數器的值:
<html>
<head>
<style>
body {
counter-reset: demo-counter;
}
p::before {
content: counter(demo-counter);
counter-increment: demo-counter;
margin: 5px;
}
</style>
</head>
<body>
<div>
<p>First Paragraph</p>
<p>Second Paragraph</p>
<p>Third Paragraph.</p>
</div>
</body>
</html>