css常用属性速查-急速查找
CSS 选择器
| 选择器 | 例子 | 例子描述 | 
|---|---|---|
| .class | .intro | 选择 class="intro" 的所有元素。 | 
| .class1.class2 | .name1.name2 | 选择 class 属性中同时有 name1 和 name2 的所有元素。 | 
| .class1 .class2 | .name1 .name2 | 选择作为类名 name1 元素后代的所有类名 name2 元素。 | 
| #id | #firstname | 选择 id="firstname" 的元素。 | 
| * | * | 选择所有元素。 | 
| element | p | 选择所有 <p> 元素。 | 
| element.class | p.intro | 选择 class="intro" 的所有 <p> 元素。 | 
| element,element | div, p | 选择所有 <div> 元素和所有 <p> 元素。 | 
| element element | div p | 选择 <div> 元素内的所有 <p> 元素。 | 
| element>element | div > p | 选择父元素是 <div> 的所有 <p> 元素。 | 
| element+element | div + p | 选择紧跟 <div> 元素的首个 <p> 元素。 | 
| element1~element2 | p ~ ul | 选择前面有 <p> 元素的每个 <ul> 元素。 | 
| [attribute] | [target] | 选择带有 target 属性的所有元素。 | 
| [attribute=value] | [target=_blank] | 选择带有 target="_blank" 属性的所有元素。 | 
| [attribute~=value] | [title~=flower] | 选择 title 属性包含单词 "flower" 的所有元素。 | 
| [attribute|=value] | [lang|=en] | 选择 lang 属性值以 "en" 开头的所有元素。 | 
| [attribute^=value] | a[href^="https"] | 选择其 src 属性值以 "https" 开头的每个 <a> 元素。 | 
| [attribute$=value] | a[href$=".pdf"] | 选择其 src 属性以 ".pdf" 结尾的所有 <a> 元素。 | 
| [attribute*=value] | a[href*="w3schools"] | 选择其 href 属性值中包含 "abc" 子串的每个 <a> 元素。 | 
| :active | a:active | 选择活动链接。 | 
| ::after | p::after | 在每个 <p> 的内容之后插入内容。 | 
| ::before | p::before | 在每个 <p> 的内容之前插入内容。 | 
| :checked | input:checked | 选择每个被选中的 <input> 元素。 | 
| :default | input:default | 选择默认的 <input> 元素。 | 
| :disabled | input:disabled | 选择每个被禁用的 <input> 元素。 | 
| :empty | p:empty | 选择没有子元素的每个 <p> 元素(包括文本节点)。 | 
| :enabled | input:enabled | 选择每个启用的 <input> 元素。 | 
| :first-child | p:first-child | 选择属于父元素的第一个子元素的每个 <p> 元素。 | 
| ::first-letter | p::first-letter | 选择每个 <p> 元素的首字母。 | 
| ::first-line | p::first-line | 选择每个 <p> 元素的首行。 | 
| :first-of-type | p:first-of-type | 选择属于其父元素的首个 <p> 元素的每个 <p> 元素。 | 
| :focus | input:focus | 选择获得焦点的 input 元素。 | 
| :fullscreen | :fullscreen | 选择处于全屏模式的元素。 | 
| :hover | a:hover | 选择鼠标指针位于其上的链接。 | 
| :in-range | input:in-range | 选择其值在指定范围内的 input 元素。 | 
| :indeterminate | input:indeterminate | 选择处于不确定状态的 input 元素。 | 
| :invalid | input:invalid | 选择具有无效值的所有 input 元素。 | 
| :lang(language) | p:lang(it) | 选择 lang 属性等于 "it"(意大利)的每个 <p> 元素。 | 
| :last-child | p:last-child | 选择属于其父元素最后一个子元素每个 <p> 元素。 | 
| :last-of-type | p:last-of-type | 选择属于其父元素的最后 <p> 元素的每个 <p> 元素。 | 
| :link | a:link | 选择所有未访问过的链接。 | 
| :not(selector) | :not(p) | 选择非 <p> 元素的每个元素。 | 
| :nth-child(n) | p:nth-child(2) | 选择属于其父元素的第二个子元素的每个 <p> 元素。 | 
| :nth-last-child(n) | p:nth-last-child(2) | 同上,从最后一个子元素开始计数。 | 
| :nth-of-type(n) | p:nth-of-type(2) | 选择属于其父元素第二个 <p> 元素的每个 <p> 元素。 | 
| :nth-last-of-type(n) | p:nth-last-of-type(2) | 同上,但是从最后一个子元素开始计数。 | 
| :only-of-type | p:only-of-type | 选择属于其父元素唯一的 <p> 元素的每个 <p> 元素。 | 
| :only-child | p:only-child | 选择属于其父元素的唯一子元素的每个 <p> 元素。 | 
| :optional | input:optional | 选择不带 "required" 属性的 input 元素。 | 
| :out-of-range | input:out-of-range | 选择值超出指定范围的 input 元素。 | 
| ::placeholder | input::placeholder | 选择已规定 "placeholder" 属性的 input 元素。 | 
| :read-only | input:read-only | 选择已规定 "readonly" 属性的 input 元素。 | 
| :read-write | input:read-write | 选择未规定 "readonly" 属性的 input 元素。 | 
| :required | input:required | 选择已规定 "required" 属性的 input 元素。 | 
| :root | :root | 选择文档的根元素。 | 
| ::selection | ::selection | 选择用户已选取的元素部分。 | 
| :target | #news:target | 选择当前活动的 #news 元素。 | 
| :valid | input:valid | 选择带有有效值的所有 input 元素。 | 
| :visited | a:visited | 选择所有已访问的链接。 | 
CSS 函数
| 函数 | 描述 | 
|---|---|
| attr() | 返回所选元素的属性值。 | 
| calc() | 允许您执行计算来确定 CSS 属性值。 | 
| cubic-bezier() | 定义三次贝塞尔曲线。 | 
| hsl() | 使用色相-饱和度-亮度模型(HSL)定义颜色。 | 
| hsla() | 使用色相-饱和度-亮度-阿尔法模型(HSLA)定义颜色。 | 
| linear-gradient() | 将线性渐变设置为背景图像。定义至少两种颜色(从上到下)。 | 
| radial-gradient() | 将径向渐变设置为背景图像。定义至少两种颜色(从中心到边缘)。 | 
| repeating-linear-gradient() | 重复线性渐变。 | 
| repeating-radial-gradient() | 重复径向渐变。 | 
| rgb() | 使用红-绿-蓝模型(RGB)定义颜色。 | 
| rgba() | 使用红-绿-蓝-阿尔法模型(RGB)定义颜色。 | 
| var() | 插入自定义属性的值。 | 
HTML 元素的 CSS 默认值
| 元素 | 默认的 CSS 值 | TIY | 
|---|---|---|
| a:link | 
 | 试一试 | 
| a:visited | 
 | 试一试 | 
| a:link:active | color: (internal value); | 试一试 | 
| a:visited:active | color: (internal value); | 试一试 | 
| abbr | None. | |
| address | 
 | 试一试 | 
| area | display: none; | |
| article | display: block; | |
| aside | display: block; | |
| audio | None. | |
| b | font-weight: bold; | 试一试 | 
| base | None. | |
| bdi | None. | |
| bdo | unicode-bidi: bidi-override; | |
| blockquote | 
 | 试一试 | 
| body | 
 | 试一试 | 
| body:focus | outline: none; | 试一试 | 
| br | None. | |
| button | None | |
| canvas | None. | |
| caption | 
 | 试一试 | 
| cite | font-style: italic; | 试一试 | 
| code | font-family: monospace; | 试一试 | 
| col | display: table-column; | 试一试 | 
| colgroup | display: table-column-group | 试一试 | 
| datalist | display: none; | |
| dd | 
 | 试一试 | 
| del | text-decoration: line-through; | 试一试 | 
| details | display: block; | |
| dfn | font-style: italic; | 试一试 | 
| dialog | None. | |
| div | display: block; | 试一试 | 
| dl | 
 | 试一试 | 
| dt | display: block; | 试一试 | 
| em | font-style: italic; | 试一试 | 
| embed:focus | outline: none; | |
| fieldset | 
 | 试一试 | 
| figcaption | display: block; | |
| figure | 
 | 试一试 | 
| footer | display: block; | |
| form | 
 | 试一试 | 
| h1 | 
 | 试一试 | 
| h2 | 
 | 试一试 | 
| h3 | 
 | 试一试 | 
| h4 | 
 | 试一试 | 
| h5 | 
 | 试一试 | 
| h6 | 
 | 试一试 | 
| head | display: none; | |
| header | display: block; | |
| hr | 
 | 试一试 | 
| html | 
 | |
| i | font-style: italic; | 试一试 | 
| iframe:focus | outline: none; | |
| iframe[seamless] | display: block; | |
| img | display: inline-block; | 试一试 | 
| input | None. | |
| ins | text-decoration: underline; | 试一试 | 
| kbd | font-family: monospace; | 试一试 | 
| label | cursor: default; | 试一试 | 
| legend | 
 | 试一试 | 
| li | display: list-item; | |
| link | display: none; | |
| main | None. | |
| map | display: inline; | |
| mark | 
 | 试一试 | 
| menu | 
 | |
| menuitem | None. | |
| meta | None. | |
| meter | None. | |
| nav | display: block; | |
| noscript | None. | |
| object:focus | outline: none; | |
| ol | 
 | 试一试 | 
| optgroup | None. | |
| option | None. | |
| output | display: inline; | |
| p | 
 | 试一试 | 
| param | display: none; | |
| picture | None. | |
| pre | 
 | 试一试 | 
| progress | None. | |
| q | display: inline; | 试一试 | 
| q::before | content: open-quote; | 试一试 | 
| q::after | content: close-quote; | 试一试 | 
| rp | None. | |
| rt | line-height: normal; | |
| ruby | None. | |
| s | text-decoration: line-through; | 试一试 | 
| samp | font-family: monospace; | |
| script | display: none; | |
| section | display: block; | 试一试 | 
| select | None. | |
| small | font-size: smaller; | 试一试 | 
| source | None. | |
| span | None. | |
| strike | text-decoration: line-through; | 试一试 | 
| strong | font-weight: bold; | 试一试 | 
| style | display: none; | |
| sub | 
 | 试一试 | 
| summary | display: block; | |
| sup | 
 | 试一试 | 
| table | 
 | 试一试 | 
| tbody | 
 | |
| td | 
 | |
| template | None. | |
| textarea | None. | |
| tfoot | 
 | |
| th | 
 | |
| thead | 
 | |
| time | None. | |
| title | display: none; | |
| tr | 
 | |
| track | None. | |
| u | text-decoration: underline; | 试一试 | 
| ul | 
 | 试一试 | 
| var | font-style: italic; | 试一试 | 
| video | None. | |
| wbr | None. | 
后续更新中...
本文来自博客园,作者:JackieDYH,转载请注明原文链接:https://www.cnblogs.com/JackieDYH/p/17634289.html

 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号