內(nèi)容概述
一 颖低、 文本屬性
1.text-decoration
設(shè)置文本的修飾外觀 (下劃線羡疗、上劃線挺物、 貫穿性 、刪除線 或者 閃爍
None 無裝飾線 可去除 a 默認下劃線
Underline : 下劃線
overline:上劃線
Line-through 中劃線
letter-spacing: 10px; 字母間的間距
word-spacing: 10px;單詞間的間距
2.text-transform 大小寫轉(zhuǎn)換
capitalize 首字符大寫
uppercase 所有字符轉(zhuǎn)換成大寫
Lowercase 所有字符轉(zhuǎn)換成小寫
none 阻止所有字符的大小寫被轉(zhuǎn)換
3. text-indent 首行縮進
4.text-align 文本對齊方式
left 左對齊
right 右對齊
center 居中對齊
justify 最后一行沒有效果 文字向兩側(cè)對齊纺棺,對最后一行無效
justify-all 和justify一致榄笙,但是強制使最后一行兩端對齊
5. font-size 設(shè)置字體大小
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="" cid="n42" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; caret-color: rgb(51, 51, 51); color: rgb(51, 51, 51); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none; background-position: inherit; background-repeat: inherit;">/* <absolute-size>,絕對大小值 */
font-size: xx-small;
font-size: x-small;
font-size: small;
font-size: medium;
font-size: large;
font-size: x-large;
font-size: xx-large;
/* <relative-size>祷蝌,相對大小值 */
font-size: larger;
font-size: smaller;
/* <length>茅撞,長度值 */
font-size: 12px;
font-size: 0.8em;
/* <percentage>,百分比值 */
font-size: 80%;
font-size: inherit;</pre>
6. font-family 設(shè)置字體 Font-weight 文本粗細
Font-weight :字體的粗細程度 一些字體只提供 normal
和 bold
兩種值 也可跟 數(shù)字 默認 400
注意 : font-weight: 700; 后面不可跟px
-
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="" cid="n48" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 0px; width: inherit; background-position: inherit; background-repeat: inherit;">normal</pre>
正常粗細。與
400等值
bold 加粗米丘。 與
700等值剑令。
font-weight
數(shù)值采取離散式定義(使用 100 的整倍數(shù))。數(shù)值為實數(shù)拄查,非 100 的整數(shù)倍的值將被四舍五入轉(zhuǎn)換為 100 的整倍數(shù)吁津,遇到 *50 時,將向上轉(zhuǎn)換堕扶,如 150 將轉(zhuǎn)換為 200
7. font-style
italic 斜體 (前提是: font-family 支持文字傾斜)
oblique 斜體 (讓文字傾斜)
8.font-variant 所有小寫字母變大寫字母 按小寫字母顯示
normal 默認值腺毫。瀏覽器會顯示一個標準的字體
small-caps 小型大寫字母的字體
inherit 規(guī)定應(yīng)該從父元素繼承 font-variant 屬性的值。
[圖片上傳失敗...(image-4ebd26-1641522383945)]
9.line-height 行高
10 字體的縮寫
font-style : font-variant: 字體變化 font-weight: 字體粗細 font-size:/ line-height: font-family:
font
屬性可以用來作為 font-style
, font-variant
, font-weight
, font-size
, line-height
和 font-family
屬性的簡寫挣柬,或?qū)⒃氐淖煮w設(shè)置為系統(tǒng)字體
簡寫的時候需要注意:
必須包含以下值: font-size font-family
可以選擇性包含以下值: font-styley font-variant font-weight line-height
font-style,font-variant睛挚,font-weight 必須在font-sitze之前
line-height必須在font-size后 用/ 分割 eg 16px/30
-
Font-fimily必須最后指定
/* font: 40px/2 "Fira Sans", serif; */
/* font: italic 1.2em "Fira Sans", serif; */
/* font: oblique small-caps 40px/60px serif; */
/* font: 24px sans-serif; */
三 邪蛔、 選擇器
通配選擇器 *
元素選擇器
類元素選擇器
ID選擇器
-
屬性選擇器
按照給定的屬性,選擇所有匹配的元素扎狱。 語法:
[attr]
只要有attr屬性[attr=value]
[attr~=value]
[attr|=value]
恰好等于 value 或者以 單詞value 開頭 后緊跟連字符 -[attr^=value]
以 value開頭[attr$=value]
以value 結(jié)尾[attr*=value]
包含value 例子:[autoplay]
選擇所有具有autoplay
屬性的元素(不論這個屬性的值是什么 -
后代選擇器 : (空格)組合器選擇前一個元素的后代節(jié)點侧到。
/* 選中div 底下的span 包括直接和間接 */
div span{
color: red;
}
-
子選擇器 :
>
組合器選擇前一個元素的直接子代的節(jié)點div > span{
color: red;
}
-
鄰兄弟選擇器 :
+
組合器選擇相鄰元素,即后一個元素緊跟在前一個之后淤击,并且共享同一個父節(jié)點匠抗。/* div 緊挨著的p */
div + p{
color: red;
}
-
全兄弟選擇器 :
~
組合器選擇兄弟元素,也就是說污抬,后一個節(jié)點在前一個節(jié)點后面的任意位置汞贸,并且共享同一個父節(jié)點。/* div 全兄弟選擇器 p */
div ~ p{
color: red;
}
-
交集選擇器 :同時符合兩個
/* div 和 class 為.one */
div.one{
color: red;
}
-
并集選擇器 :
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="" cid="n222" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; background-position: inherit; background-repeat: inherit;">, 是將不同的選擇器組合在一起的方法印机,它選擇所有能被列表中的任意一個選擇器選中的節(jié)點矢腻。
語法:A, B</pre> -
偽選擇器
:
偽選擇器支持按照未被包含在文檔樹中的狀態(tài)信息來選擇元素。 例子:a:visited
匹配所有曾被訪問過的 `` 元素射赛。::
偽選擇器用于表示無法用 HTML 語義表達的實體多柑。 例子:p::first-line
匹配所有 `` 元素的第一行。
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="" cid="n434" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; caret-color: rgb(51, 51, 51); color: rgb(51, 51, 51); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none; background-position: inherit; background-repeat: inherit;"><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
/* 選中div 底下的span 包括直接和間接 /
/ div span{
color: red;
} /
/ 后代選擇器 3 4 5/
/ div span{
color: red;
} */
/* 前一個元素的直接子代節(jié)點 3 4 5 /
/ div > span{
color: red;
} */
/* 兄弟節(jié)點 具有共同父節(jié)點 div 后緊挨著span 7 /
/ div + span{
color: red;
} */
/* 兄弟全節(jié)點 后節(jié)點在前一個節(jié)點后面的 任意位置 78/
/ div ~ span{
color: red;
} */
/* 交集 234568 /
/ div.one{
color: red;
} */
/* 后代選擇器 6 /
/ div .one{
color: red;
} */
/* 并集選擇器 楣责,隔開 234568 79 下面只要符合其中一個就滿足條件 */
div, .one , [title="test"]{
color: red;
}
</style>
</head>
<body>
<span>文字內(nèi)容1</span>
<div class="one"> 文字內(nèi)容2
<span>
文字內(nèi)容3
<p>
文字內(nèi)容4
</p>
</span>
<span>文字內(nèi)容5</span>
<div class="one">文字內(nèi)容6</div>
<span>內(nèi)容8</span>
</div>
<span class="one">文字內(nèi)容7</span>
<a href="" tabindex="-1"></a>
<p title="test">內(nèi)容9</p>
</body>
</html></pre>
四竣灌、 偽類 (pseudo-class) 和偽元素
1. 常見的偽類
-
動態(tài)偽類 : 順序有要求
使用時特別注意: :hover 必須放在 :link 和:visited后面才能完全生效
:active必須放在 : hover后面才能完全生效
女朋友看到 LV后 haha 大笑
女朋友看到LV后 瘋(:focus)了樣的哈哈大笑
:link a:link 未訪問的狀態(tài)
:visited a:visited 已訪問的狀態(tài)
-
:hover 鼠標放 在鏈接上的顏色 (也可放在別的元素上)
strong:hover{
}
:active 激活的鏈接(鼠標在鏈接上長按住未松開)
-
:focus 獲取焦點
去掉a元素的焦點狀態(tài)
a:focus{
outline: none;
}
<a href="" tabindex="-1"></a>
tabindex 可以調(diào)整tab選中元素的順序
動態(tài)偽類eg:
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="" cid="n438" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; background-position: inherit; background-repeat: inherit;"><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title><style>
/* 未訪問 /
a:link{
color: red;
}
/ 已訪問 /
a:visited{
color: green;
}
/ 手指放上去 /
a:hover{
color: #600;
}
/ 活躍的時候 手指點下去 未松手 */
a:active{
color: rgb(34, 34, 34);
}</style>
</head>
<body>
<a href="#"> 百度一下</a>
</body>
</html></pre> -
目標偽類: :taget
目標偽類:target eg
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="" cid="n449" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; background-position: inherit; background-repeat: inherit;"><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
:target{
color: red;
}
</style>
</head>
<body>
<a href="#title1">標題1</a>
<a href="#title2">標題2</a>
<a href="#title3">標題3</a>
<h2 id="title1">標題1</h2>
<p>我是內(nèi)容1</p>
<p>我是內(nèi)容1</p>
<p>我是內(nèi)容1</p>
<p>我是內(nèi)容1</p>
<p>我是內(nèi)容1</p>
<p>我是內(nèi)容1</p>
<p>我是內(nèi)容1</p>
<p>我是內(nèi)容1</p>
<p>我是內(nèi)容1</p>
<p>我是內(nèi)容1</p>
<p>我是內(nèi)容1</p>
<p>我是內(nèi)容1</p>
<p>我是內(nèi)容1</p>
<p>我是內(nèi)容1</p>
<p>我是內(nèi)容1</p>
<p>我是內(nèi)容1</p>
<p>我是內(nèi)容1</p>
<p>我是內(nèi)容1</p>
<p>我是內(nèi)容1</p>
<p>我是內(nèi)容1</p>
<p>我是內(nèi)容1</p>
<p>我是內(nèi)容1</p>
<p>我是內(nèi)容1</p>
<h2 id="title2">標題2</h2>
<p>我是內(nèi)容222</p>
<p>我是內(nèi)容222</p>
<p>我是內(nèi)容222</p>
<p>我是內(nèi)容222</p>
<p>我是內(nèi)容222</p>
<p>我是內(nèi)容222</p>
<p>我是內(nèi)容222</p>
<p>我是內(nèi)容222</p>
<p>我是內(nèi)容222</p>
<p>我是內(nèi)容222</p>
<p>我是內(nèi)容222</p>
<p>我是內(nèi)容222</p>
<p>我是內(nèi)容222</p>
<p>我是內(nèi)容222</p>
<p>我是內(nèi)容222</p>
<p>我是內(nèi)容222</p>
<p>我是內(nèi)容222</p>
<p>我是內(nèi)容222</p>
<p>我是內(nèi)容222</p>
<h2 id="title3">標題3</h2>
<p>我是內(nèi)容3</p>
<p>我是內(nèi)容3</p>
<p>我是內(nèi)容3</p>
<p>我是內(nèi)容3</p>
<p>我是內(nèi)容3</p>
<p>我是內(nèi)容3</p>
<p>我是內(nèi)容3</p>
<p>我是內(nèi)容3</p>
<p>我是內(nèi)容3</p>
<p>我是內(nèi)容3</p>
<p>我是內(nèi)容3</p>
<p>我是內(nèi)容3</p>
<p>我是內(nèi)容3</p>
<p>我是內(nèi)容3</p>
<p>我是內(nèi)容3</p>
<p>我是內(nèi)容3</p>
<p>我是內(nèi)容3</p>
<p>我是內(nèi)容3</p>
<p>我是內(nèi)容3</p>
<p>我是內(nèi)容3</p>
<p>我是內(nèi)容3</p>
<p>我是內(nèi)容3</p>
</body>
</html></pre>
語言偽類: :lang()
-
元素狀態(tài)偽類: :disabled
Eg:
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="" cid="n455" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; background-position: inherit; background-repeat: inherit;"><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title><style>
/* button[disabled]{
color: red;
} */
:disabled{
color: red;
}</style>
</head>
<body>
<button disabled>我是按鈕</button>
<button >我是按鈕</button></body>
</html></pre> -
結(jié)構(gòu)偽類
- :nth-child(1) 選中第幾個子類
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="" cid="n471" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; background-position: inherit; background-repeat: inherit;"><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
/* 選中子元素的第三個 /
/ :nth-child(3){
color: red;
} *//* 選中子元素的自然數(shù) /
/ :nth-child(n){
color: red;
} *//* 倒數(shù)第三個 /
/ :nth-last-child(3){
color: red;
} *//* 同類型下第都3個 忽略別的元素 */
:nth-of-type(3){
color: red;}
</style>
</head>
<body>
<div>
<p>文字內(nèi)容1</p>
<p>文字內(nèi)容2</p>
<p>文字內(nèi)容3</p>
<p>文字內(nèi)容4</p>
<p>文字內(nèi)容5</p>
<p>文字內(nèi)容6</p>
<p>文字內(nèi)容7</p>
<p>文字內(nèi)容8</p>
<p>文字內(nèi)容9</p>
</div></body>
</html></pre> -
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="" cid="n474" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 0px; width: inherit; background-position: inherit; background-repeat: inherit;"> /* 父元素中唯一子元素 */
span:only-child{
color: red;
}</pre><pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="" cid="n475" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; background-position: inherit; background-repeat: inherit;"> /* 是父元素中唯一的這種類型的子元素 */
:only-of-type{
color: red;
}</pre><pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="" cid="n480" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; background-position: inherit; background-repeat: inherit;"> /* 元素為空 */
:empty{
height: 20px;
columns: red;
}</pre><pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="" cid="n481" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; background-position: inherit; background-repeat: inherit;"> /* 否定偽類 除啦html 除啦body 除啦div之外的所有元素*/
:not(html):not(body):not(div){
color: red;
}
</pre> -
常見的偽元素
- :first-letter 第一個字母
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="" cid="n493" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; background-position: inherit; background-repeat: inherit;"> p::first-letter{
font-size: 50px;
}</pre><pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="" cid="n503" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 0px; width: inherit; background-position: inherit; background-repeat: inherit;">第一行
p::first-line{
font-size: 50px;
}</pre>::before 在某元素前加內(nèi)容
-
::after 在后邊加元素
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="" cid="n512" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; background-position: inherit; background-repeat: inherit;"> span::before{
content: "1323";
color: red;
}</pre>
五、 Emment元素
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="" cid="n260" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; caret-color: rgb(51, 51, 51); color: rgb(51, 51, 51); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none; background-position: inherit; background-repeat: inherit;"><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div class="box"></div>
<div id="title"></div>
<div id="main">
<div class="box"></div>
<p class="p1"></p>
<span class="title"></span>
</div>
<div class="footer"></div>
<div id="header" class="box box2" title="hhah哈ha"></div>
</body>
</html>
</pre>
div#title id屬性 #
div.box 類 .
上一級 ^ div#main>div.box+p.p1+span.title^div.footer>span
屬性內(nèi)容帶數(shù)字 {內(nèi)容
}*5
-
css隱式
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="" cid="n548" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; background-position: inherit; background-repeat: inherit;"><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
div{
/* w200 */
width: 100px;/* h200 */
height: 200px;/* m20 */
margin: 20px;/* p20 */
padding: 20px;/* fz20 */
font-size: 20px;/* fw700 /
font-weight: 700;
/ lh50px 行高需要加px */
line-height: 50px;}
</style>
</head>
<body><div></div>
</body>
</html></pre> -
隱式寫法 eg
<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="" cid="n538" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; background-position: inherit; background-repeat: inherit;"> lv可以不寫 一樣的效果
li>lv.item}*5
.container 會自動補齊 div
<div class="container"></div></pre>