HTML及CSS基礎課(十) 用class和id為div設定風格

來源:互聯網
上載者:User

這節課主要是複習一下前一課的內容,會用div來建立幾個圓圈,讓用class和id來給他們設定風格。

其中涉及到的屬性:

display: inline-block

border-radius: 100%;

margin-left: 5px

將會在後面課程有講

stylesheet.css

/*Add your CSS below!*/        div {      display: inline-block;      margin-left: 5px;      height: 100px;        width: 100px;      border-radius: 100%;      border: 2px solid black;  }  .friend {      border: 2px dashed #008000;  }  .family {      border: 2px dashed #0000FF;  }  .enemy {      border: 2px dashed #FF0000;  }  #best_friend {      border: 4px solid #00C957;  }  #archnemesis {      border: 4px solid #CC0000;  }

index.html

<!DOCTYPE html>  <html>      <head>          <link type="text/css" rel="stylesheet" href="stylesheet.css" />          <title>My Social Network</title>      </head>      <body>          <!--Add your HTML below!-->        <div class="friend" id = "best_friend"> </div>          <div class="family"> </div>          <div class="enemy" id = "archnemesis"> </div>      </body>  </html>

更多精彩內容:http://www.bianceng.cn/web/Html/

效果圖:

從效果可以看出,class friend 和id best_friend還有enemy和archnemesis都同時被一個div引用,結果顯示的效果是best_friend的,說明了id的優先順序比class更高。

聯繫我們

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