使用選取器在頁面中插入內容,選取器頁面

來源:互聯網
上載者:User

使用選取器在頁面中插入內容,選取器頁面

轉載請註明文章出處:http://blog.csdn.net/lindonglian/article/details/46470455

使用選取器在頁面中插入文字

<!DOCTYPE html><html lang="en" xmlns="http://www.w3.org/1999/xhtml"><head>    <meta charset="utf-8" />    <title></title>    <style type="text/css">        p:before        {            content: '你好,';            color: white;            background-color: orange;            font-family: '黑體';        }        p:after        {            content: ',見到你很高興!';            color: white;            background-color: orange;            font-family: 黑體;        }        p.zhang:after        {            content: none;        }        p.zhang:before        {            content: none;        }    </style></head><body>    <p>小紅</p>    <p class="zhang">張林</p>    <p>王強</p></body></html>


在標題前插入影像檔

<!DOCTYPE html><html lang="en" xmlns="http://www.w3.org/1999/xhtml"><head>    <meta charset="utf-8" />    <title></title>    <style type="text/css">        h1:after        {            content: url(img.png);        }    </style></head><body>    <p>王強</p></body></html>
在CSS3中,使用content屬性的attr(屬性名稱)來指定attr的值。這樣可以將某個屬性的屬性值顯示出來。
<!DOCTYPE html><html lang="en" xmlns="http://www.w3.org/1999/xhtml"><head>    <meta charset="utf-8" />    <title></title>    <style type="text/css">        img:after        {            content: attr(alt);            display: block;        }    </style></head><body>    <p align="center">        <img src="xp.png" alt="系統圖片" width="200" height="200" />    </p></body></html>
添加編號
<!DOCTYPE html><html lang="en" xmlns="http://www.w3.org/1999/xhtml"><head>    <meta charset="utf-8" />    <title></title>    <style type="text/css">        h3:before        {            content: '第'counter(count)'章';            color: red;            font-family: 黑體;            font-size: 24px;        }        h3        {            counter-increment: count;        }    </style></head><body>    <h3>HTML5簡介</h3>    <h3>HTML5結構</h3>    <h3>多媒體播放</h3>    <h3>本機存放區</h3>    <h3>表單與檔案</h3>    <h3>新增元素</h3></body></html>


使用before選取器或after選取器的counter屬性,不但可以在編號中追迴文字和設定樣式,還可以為編號設定編號類型。

指定編號類型可以使用list-style-type屬性,常用的編號種類介紹如下:


<!DOCTYPE html><html lang="en" xmlns="http://www.w3.org/1999/xhtml"><head>    <meta charset="utf-8" />    <title></title>    <style type="text/css">        h1:before        {            content: counter(count, upper-roman)'.';            color: red;            font-family: 黑體;        }        h1        {            counter-increment: count;        }        h2:before        {            content: counter(count1)'.';            color: red;            font-family: 黑體;        }        h2        {            counter-increment: count1;            margin-left: 50px;        }    </style></head><body>    <h1>建立網站及網站資訊</h1>    <h2>網站建設理論</h2>    <h1>安裝IIS伺服器</h1>    <h2>網站管理</h2>    <h1>網站欄目及版塊設計</h1>    <h2>網頁文本概述</h2>    <h1>設計產品資訊版塊</h1>    <h2>多彩文字設計</h2></body></html>

在符號兩邊嵌入文字元號

<!DOCTYPE html><html lang="en" xmlns="http://www.w3.org/1999/xhtml"><head>    <meta charset="utf-8" />    <title></title>    <style type="text/css">        h1:before        {            content: open-quote;            color: red;            font-family: 黑體;        }        h1:after        {            content: close-quote;            color: red;            font-family: 黑體;        }        h1        {            quotes: "《" "》";        }    </style></head><body>    <h1>ASP基礎教程與實驗指導</h1>    <h1>電腦群組裝</h1>    <h1>HTML5從新手到高手</h1></body></html>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.