CSS筆記二.....

來源:互聯網
上載者:User

標籤:

1.選擇符:

a.關係選擇符:

1).E F :包含選擇符,選擇所有被E包含的F元素。例如:

<style>             p h1 {                         color:red;              }</style>
<body> <p> <h1>嘻嘻</h1> <h1>嘻嘻</h1> </p> </body>

2).子選擇符:E > F,選擇所有作為E元素的子項目F。例如:

<style>             p  > font {                         color:red;              }</style>
<body> <p> <font>嘻嘻</font> <font><a>嘻嘻</a></font> </p> </body>

3).相鄰選擇符:E + F,選擇緊貼在E元素之後的F元素。例如:

<style>             p + h1 {                         color:red;              }</style>
<body> <p> <h1>嘻嘻</h1> <a>嘻嘻</a> </p> </body>

4).兄弟選擇符:E~F,選擇E元素之後所有兄弟元素F。例如:

<style>             p ~ h1 {                         color:red;              }
</style>
<body> <p> <h1>嘻嘻</h1> <h1>嘻嘻</h1> </p> </body>

5).id和class選擇符:id/class選取器可以為標有特定ID/class的元素指定樣式。例如:

<style>           #nav {          font-size:12px;}          .header {           background:red;}</style><body>        <p id="nav">哈哈</p>        <header class="header">呵呵</head></body>

6).偽類選擇符:這裡列舉一些常用的。例如:

a標籤的偽類選擇符:
<style> a:link { color:red; } a:visited { color:blue; } a:hover { color:yellow; } a:active { color:green; }</style><body> <a>我是a標籤</a></body>
input標籤的偽類選擇符:<style>          input:focus {               outline:1px solid red;          }          iuput:checked {               color:red;         }         input:disable {               font-weidh:20px        }        input:enable {                font-weight:30px;        }</style><body>        <input type="text" name="" value="" id="" / >        <input type="text" name="" value="" id="" checked/ >        <input type="text" name="" value="" id="" disable/ >        <input type="text" name="" value="" id="" enable/ ></body>
<style>         ul  li:first-child {color:red;}         ul li:last-child {color:blue;}         ul li:nth-child(3) {color:yellow;}         ul li:nth-last-child(2) {color:green;}</style><body>          <ul>                  <li>第一個li</li>                  <li>第一個li</li>                  <li>第一個li</li>                  <li>第一個li</li>         </ul></body>
偽類:E:target,匹配相關URL指向的E元素,和錨點差不多。例如:<style>         a:target {            outline:2px dashed blue;         }</style><body><a href="#aaa" id="aaa">嘻嘻</a><a href="#bbb" id="bbb">哈哈</a><a href="#ccc" id="ccc">嘿嘿</a></body>
實現奇偶行樣式:<style>              //奇數行樣式;            .ul2 li:nth-child(odd){background:red;}             //偶數行樣式;            .ul2 li:nth-child(even){background:#0F7CCF;}            //3的倍數;           .ol2 li:nth-child(3n){background:yellow;}</style><body>     <ul class="ul2">            <li>test1</li>            <li>test2</li>            <li>test3</li>            <li>test4</li>            <li>test5</li>            <li>test6</li>     </ul>     <ol class="ol2">            <li>test1</li>            <li>test2</li>            <li>test3</li>            <li>test4</li>            <li>test5</li>            <li>test6</li>     </ol></body>

  

CSS筆記二.....

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.