Latest web development tutorials
×

CSS 參考手冊

CSS 參考手冊 CSS 選擇器 CSS 語音參考 CSS Web 安全字體 CSS 動畫 CSS 單位 CSS 顏色 CSS 合法顏色值 CSS 顏色名稱 CSS 顏色十六進制值 CSS 瀏覽器支持

CSS 屬性

align-content align-items align-self all animation animation-delay animation-direction animation-duration animation-fill-mode animation-iteration-count animation-name animation-play-state animation-timing-function appearance backface-visibility background background-attachment background-blend-mode background-clip background-color background-image background-origin background-position background-repeat background-size border border-bottom border-bottom-color border-bottom-left-radius border-bottom-right-radius border-bottom-style border-bottom-width border-collapse border-color border-image border-image-outset border-image-repeat border-image-slice border-image-source border-image-width border-left border-left-color border-left-style border-left-width border-radius border-right border-right-color border-right-style border-right-width border-spacing border-style border-top border-top-color border-top-left-radius border-top-right-radius border-top-style border-top-width border-width bottom box-align box-direction box-flex box-flex-group box-lines box-ordinal-group box-orient box-pack box-shadow box-sizing caption-side clear clip color column-count column-fill column-gap column-rule column-rule-color column-rule-style column-rule-width column-span column-width columns content counter-increment counter-reset cursor direction display empty-cells filter flex flex-basis flex-direction flex-flow flex-grow flex-shrink flex-wrap float font @font-face font-family font-size font-size-adjust font-stretch font-style font-variant font-weight grid-columns grid-rows hanging-punctuation height icon justify-content @keyframes left letter-spacing line-height list-style list-style-image list-style-position list-style-type margin margin-bottom margin-left margin-right margin-top max-height max-width @media min-height min-width nav-down nav-index nav-left nav-right nav-up opacity order outline outline-color outline-offset outline-style outline-width overflow overflow-x overflow-y padding padding-bottom padding-left padding-right padding-top page-break-after page-break-before page-break-inside perspective perspective-origin position punctuation-trim quotes resize right rotation tab-size table-layout target target-name target-new target-position text-align text-align-last text-decoration text-decoration-color text-decoration-line text-decoration-style text-indent text-justify text-outline text-overflow text-shadow text-transform text-wrap top transform transform-origin transform-style transition transition-delay transition-duration transition-property transition-timing-function unicode-bidi vertical-align visibility white-space width word-break word-spacing word-wrap z-index

CSS 選擇器

CSS選擇器用於選擇你想要的元素的樣式的模式。

"CSS"列表示在CSS版本的屬性定義(CSS1,CSS2,或對CSS3)。

選擇器 示例 示例說明 CSS
.class .intro 選擇所有class="intro"的元素 1
# id #firstname 選擇所有id="firstname"的元素 1
* * 選擇所有元素 2
elementp 選擇所有<p>元素 1
element,elementdiv,p 選擇所有<div>元素和<p>元素 1
elementelement div p 選擇<div>元素內的所有<p>元素 1
element>element div>p 選擇所有父級是<div> 元素的<p> 元素 2
element+element div+p 選擇所有緊接著<div>元素之後的<p>元素 2
[ attribute] [target] 選擇所有帶有target屬性元素 2
[attribute=value] [target=-blank] 選擇所有使用target="-blank"的元素 2
[attribute~=value] [title~=flower] 選擇標題屬性包含單詞"flower"的所有元素 2
[attribute|=language] [lang|=en] 選擇一個lang屬性的起始值="EN"的所有元素 2
:link a:link 選擇所有未訪問鏈接 1
:visited a:visited 選擇所有訪問過的鏈接 1
:active a:active 選擇活動鏈接 1
:hover a:hover 選擇鼠標在鏈接上面時 1
:focus input:focus 選擇具有焦點的輸入元素 2
:first-letter p:first-letter 選擇每一個<P>元素的第一個字母 1
:first-line p:first-line 選擇每一個<P>元素的第一行 1
:first-child p:first-child 指定只有當<p>元素是其父級的第一個子級的樣式。 2
:before p:before 在每個<p>元素之前插入內容 2
:after p:after 在每個<p>元素之後插入內容 2
:lang(language) p:lang(it) 選擇一個lang屬性的起始值="it"的所有<p>元素 2
element1 ~element2 p~ul 選擇p元素之後的每一個ul元素 3
[ attribute^=value] a[src^="https"] 選擇每一個src屬性的值以"https"開頭的元素 3
[attribute$=value] a[src$=".pdf"] 選擇每一個src屬性的值以".pdf"結尾的元素 3
[attribute*=value] a[src*="w3big"] 選擇每一個src屬性的值包含子字符串"w3big"的元素 3
:first-of-type p:first-of-type 選擇每個p元素是其父級的第一個p元素 3
:last-of-type p:last-of-type 選擇每個p元素是其父級的最後一個p元素 3
:only-of-type p:only-of-type 選擇每個p元素是其父級的唯一p元素 3
:only-child p:only-child 選擇每個p元素是其父級的唯一子元素 3
:nth-child(n) p:nth-child(2) 選擇每個p元素是其父級的第二個子元素 3
:nth-last-child(n) p:nth-last-child(2) 選擇每個p元素的是其父級的第二個子元素,從最後一個子項計數 3
:nth-of-type(n) p:nth-of-type(2) 選擇每個p元素是其父級的第二個p元素 3
:nth-last-of-type(n) p:nth-last-of-type(2) 選擇每個p元素的是其父級的第二個p元素,從最後一個子項計數 3
:last-child p:last-child 選擇每個p元素是其父級的最後一個子級。 3
:root :root 選擇文檔的根元素 3
:empty p:empty 選擇每個沒有任何子級的p元素(包括文本節點) 3
:target #news:target 選擇當前活動的#news元素(包含該錨名稱的點擊的URL) 3
:enabled input:enabled 選擇每一個已啟用的輸入元素 3
:disabled input:disabled 選擇每一個禁用的輸入元素 3
:checked input:checked 選擇每個選中的輸入元素 3
:not(selector) :not(p) 選擇每個並非p元素的元素 3
::selection ::selection 匹配元素中被用戶選中或處於高亮狀態的部分 3
:out-of-range :out-of-range 匹配值在指定區間之外的input元素 3
:in-range :in-range 匹配值在指定區間之內的input元素 3
:read-write :read-write 用於匹配可讀及可寫的元素 3
:read-only :read-only 用於匹配設置"readonly"(只讀) 屬性的元素 3
:optional :optional 用於匹配可選的輸入元素 3
:required :required 用於匹配設置了"required" 屬性的元素 3
:valid :valid 用於匹配輸入值為合法的元素 3
:invalid :invalid 用於匹配輸入值為非法的元素 3