<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # CSS 偽類 (Pseudo-classes) **CSS 偽類用于向某些選擇器添加特殊的效果。** ## CSS 偽類 (Pseudo-classes)實例: [超鏈接](/tiy/t.asp?f=csse_link) ``` &lt;html&gt; &lt;head&gt; &lt;style type="text/css"&gt; a:link {color: #FF0000} a:visited {color: #00FF00} a:hover {color: #FF00FF} a:active {color: #0000FF} &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;p&gt;&lt;b&gt;&lt;a href="/index.html" target="_blank"&gt;這是一個鏈接。&lt;/a&gt;&lt;/b&gt;&lt;/p&gt; &lt;p&gt;&lt;b&gt;注釋:&lt;/b&gt;在 CSS 定義中,a:hover 必須位于 a:link 和 a:visited 之后,這樣才能生效!&lt;/p&gt; &lt;p&gt;&lt;b&gt;注釋:&lt;/b&gt;在 CSS 定義中,a:active 必須位于 a:hover 之后,這樣才能生效!&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; ``` [超鏈接 2](/tiy/t.asp?f=csse_link2) ``` &lt;html&gt; &lt;head&gt; &lt;style type="text/css"&gt; a.one:link {color: #ff0000} a.one:visited {color: #0000ff} a.one:hover {color: #ffcc00} a.two:link {color: #ff0000} a.two:visited {color: #0000ff} a.two:hover {font-size: 150%} a.three:link {color: #ff0000} a.three:visited {color: #0000ff} a.three:hover {background: #66ff66} a.four:link {color: #ff0000} a.four:visited {color: #0000ff} a.four:hover {font-family: monospace} a.five:link {color: #ff0000; text-decoration: none} a.five:visited {color: #0000ff; text-decoration: none} a.five:hover {text-decoration: underline} &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;p&gt;請把鼠標移動到這些鏈接上,以查看效果:&lt;/p&gt; &lt;p&gt;&lt;b&gt;&lt;a class="one" href="/index.html" target="_blank"&gt;這個鏈接改變顏色&lt;/a&gt;&lt;/b&gt;&lt;/p&gt; &lt;p&gt;&lt;b&gt;&lt;a class="two" href="/index.html" target="_blank"&gt;這個鏈接改變字體大小&lt;/a&gt;&lt;/b&gt;&lt;/p&gt; &lt;p&gt;&lt;b&gt;&lt;a class="three" href="/index.html" target="_blank"&gt;這個鏈接改變背景顏色&lt;/a&gt;&lt;/b&gt;&lt;/p&gt; &lt;p&gt;&lt;b&gt;&lt;a class="four" href="/index.html" target="_blank"&gt;這個鏈接改變字體系列&lt;/a&gt;&lt;/b&gt;&lt;/p&gt; &lt;p&gt;&lt;b&gt;&lt;a class="five" href="/index.html" target="_blank"&gt;這個鏈接改變文本裝飾&lt;/a&gt;&lt;/b&gt;&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; ``` [超鏈接 - :focus 的使用](/tiy/t.asp?f=csse_link_focus) ``` &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html&gt; &lt;head&gt; &lt;style type="text/css"&gt; input:focus { background-color:yellow; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;form action="form_action.asp" method="get"&gt; First name: &lt;input type="text" name="fname" /&gt;&lt;br /&gt; Last name: &lt;input type="text" name="lname" /&gt;&lt;br /&gt; &lt;input type="submit" value="Submit" /&gt; &lt;/form&gt; &lt;p&gt;&lt;b&gt;注釋:&lt;/b&gt;如果已規定 !DOCTYPE,那么 Internet Explorer 8 (以及更高版本)支持 :focus 偽類。&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; ``` [:first-child(首個子對象)](/tiy/t.asp?f=csse_first-child) ``` &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt; &lt;html&gt; &lt;head&gt; &lt;style type="text/css"&gt; p:first-child {font-weight: bold;} li:first-child {text-transform:uppercase;} &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div&gt; &lt;p&gt;These are the necessary steps:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Intert Key&lt;/li&gt; &lt;li&gt;Turn key &lt;strong&gt;clockwise&lt;/strong&gt;&lt;/li&gt; &lt;li&gt;Push accelerator&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;Do &lt;em&gt;not&lt;/em&gt; push the brake at the same time as the accelerator.&lt;/p&gt; &lt;/div&gt; &lt;p&gt;&lt;b&gt;注釋:&lt;/b&gt;必須聲明 DOCTYPE,這樣 :first-child 才能在 IE 中生效。&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; ``` [:lang(語言)](/tiy/t.asp?f=csse_lang) ``` &lt;html&gt; &lt;head&gt; &lt;style type="text/css"&gt; q:lang(no) { quotes: "~" "~" } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;p&gt;:lang 偽類允許您為不同的語言定義特殊的規則。在下面的例子中,在下面的例子中,:lang 類為帶有值為 "no" 的 lang 屬性的 q 元素定義引號的類型:&lt;/p&gt; &lt;p&gt;一些文本 &lt;q lang="no"&gt;段落中的引用&lt;/q&gt; 一些文本。&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; ``` ## 語法 偽類的語法: ``` selector : pseudo-class {property: value} ``` CSS 類也可與偽類搭配使用。 ``` selector.class : pseudo-class {property: value} ``` ## 錨偽類 在支持 CSS 的瀏覽器中,鏈接的不同狀態都可以不同的方式顯示,這些狀態包括:活動狀態,已被訪問狀態,未被訪問狀態,和鼠標懸停狀態。 ``` a:link {color: #FF0000} /* 未訪問的鏈接 */ a:visited {color: #00FF00} /* 已訪問的鏈接 */ a:hover {color: #FF00FF} /* 鼠標移動到鏈接上 */ a:active {color: #0000FF} /* 選定的鏈接 */ ``` 提示:在 CSS 定義中,a:hover 必須被置于 a:link 和 a:visited 之后,才是有效的。 提示:在 CSS 定義中,a:active 必須被置于 a:hover 之后,才是有效的。 提示:偽類名稱對大小寫不敏感。 ## 偽類與 CSS 類 偽類可以與 CSS 類配合使用: ``` a.red : visited {color: #FF0000} <a class="red" href="css_syntax.asp">CSS Syntax</a> ``` 假如上面的例子中的鏈接被訪問過,那么它將顯示為紅色。 ## CSS2 - :first-child 偽類 您可以使用 :first-child 偽類來選擇元素的第一個子元素。這個特定偽類很容易遭到誤解,所以有必要舉例來說明。考慮以下標記: ``` <div> <p>These are the necessary steps:</p> <ul> <li>Intert Key</li> <li>Turn key <strong>clockwise</strong></li> <li>Push accelerator</li> </ul> <p>Do <em>not</em> push the brake at the same time as the accelerator.</p> </div> ``` 在上面的例子中,作為第一個元素的元素包括第一個 p、第一個 li 和 strong 和 em 元素。 給定以下規則: ``` p:first-child {font-weight: bold;} li:first-child {text-transform:uppercase;} ``` 第一個規則將作為某元素第一個子元素的所有 p 元素設置為粗體。第二個規則將作為某個元素(在 HTML 中,這肯定是 ol 或 ul 元素)第一個子元素的所有 li 元素變成大寫。 請訪問該鏈接,來查看這個 [:first-child 實例](/tiy/t.asp?f=csse_first-child)的效果。 提示:最常見的錯誤是認為 p:first-child 之類的選擇器會選擇 p 元素的第一個子元素。 注釋:必須聲明 [&lt;!DOCTYPE&gt;](/tags/tag_doctype.asp),這樣 :first-child 才能在 IE 中生效。 為了使您更透徹地理解 :first-child 偽類,我們另外提供了 3 個例子: ### 例子 1 - 匹配第一個 &lt;p&gt; 元素 在下面的例子中,選擇器匹配作為任何元素的第一個子元素的 p 元素: ``` <html> <head> <style type="text/css"> p:first-child { color: red; } </style> </head> <body> <p>some text</p> <p>some text</p> </body> </html> ``` ### 例子 2 - 匹配所有 &lt;p&gt; 元素中的第一個 &lt;i&gt; 元素 在下面的例子中,選擇器匹配所有 &lt;p&gt; 元素中的第一個 &lt;i&gt; 元素: ``` <html> <head> <style type="text/css"> p > i:first-child { font-weight:bold; } </style> </head> <body> <p>some <i>text</i>. some <i>text</i>.</p> <p>some <i>text</i>. some <i>text</i>.</p> </body> </html> ``` ### 例子 3 - 匹配所有作為第一個子元素的 &lt;p&gt; 元素中的所有 &lt;i&gt; 元素 在下面的例子中,選擇器匹配所有作為元素的第一個子元素的 &lt;p&gt; 元素中的所有 &lt;i&gt; 元素: ``` <html> <head> <style type="text/css"> p:first-child i { color:blue; } </style> </head> <body> <p>some <i>text</i>. some <i>text</i>.</p> <p>some <i>text</i>. some <i>text</i>.</p> </body> </html> ``` ## CSS2 - :lang 偽類 :lang 偽類使你有能力為不同的語言定義特殊的規則。在下面的例子中,:lang 類為屬性值為 no 的 q 元素定義引號的類型: ``` <html> <head> <style type="text/css"> q:lang(no) { quotes: "~" "~" } </style> </head> <body> <p>文字<q lang="no">段落中的引用的文字</q>文字</p> </body></html> ``` ## 偽類 _W3C_:"W3C" 列指示出該屬性在哪個 CSS 版本中定義(CSS1 還是 CSS2)。 | 屬性 | 描述 | CSS | | --- | --- | --- | | [:active](/cssref/pr_pseudo_active.asp) | 向被激活的元素添加樣式。 | 1 | | [:focus](/cssref/pr_pseudo_focus.asp) | 向擁有鍵盤輸入焦點的元素添加樣式。 | 2 | | [:hover](/cssref/pr_pseudo_hover.asp) | 當鼠標懸浮在元素上方時,向元素添加樣式。 | 1 | | [:link](/cssref/pr_pseudo_link.asp) | 向未被訪問的鏈接添加樣式。 | 1 | | [:visited](/cssref/pr_pseudo_visited.asp) | 向已被訪問的鏈接添加樣式。 | 1 | | [:first-child](/cssref/pr_pseudo_first-child.asp) | 向元素的第一個子元素添加樣式。 | 2 | | [:lang](/cssref/pr_pseudo_lang.asp) | 向帶有指定 lang 屬性的元素添加樣式。 | 2 |
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看