HTML5 and CSS: 11-20

css 選擇器、css 屬性: 字體大小、字體設定、image、border、

11 - Style Multiple Elements with a CSS Class

<style>
  .red-text {
    color: red;
  }
</style>

<h2 class="red-text">CatPhotoApp</h2>

<p class="red-text">Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>

12 - Change the Font Size of an Element

<style>
  .red-text {
    color: red;
  }
  p {
    font-size: 16px;
  }
</style>

<h2 class="red-text">CatPhotoApp</h2>

<p class="red-text">Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
<p>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>

13 - Set the Font Family of an Element

14 - Import a Google Font

  • Google 的龍蝦體(三小 ...)

15 - Specify How Fonts Should Degrade

  • 當A字體不存在,換使用B字體,就是降級的意思

  • font-family: Lobster, Monospace;

16 - Add Images to your Website

  • <img src="path" alt="some words">

  • alt 很重要,視障人士看不到圖片,只能看到 alt 的補充

this is a cat

17 - Size your Images

  • width: 500px;

18 - Add Borders Around your Elements

  • style, color, width

  • <img class="class1 class2">

19 - Add Rounded Corners with a Border Radius

  • 在 border 轉角變成圓角

20 - Make Circular Images with a Border Radius

  • 這好神奇,border-radius: 50%,圖竟然就變成圓形了

Last updated

Was this helpful?