Free Code Camp - practice
  • Introduction
  • Getting Start
    • Introduction
    • Join the Free Code Camp Community
    • 實做成果
  • Front End Development Certification
    • HTML5 and CSS
      • HTML5 and CSS: 01-10
      • HTML5 and CSS: 11-20
      • HTML5 and CSS: 21-30
      • HTML5 and CSS: 31-40
      • HTML5 and CSS: 41-50
      • HTML5 and CSS: 51-
    • Responsive Design with Bootstrap
      • Bootstrap 01-10
      • Bootstrap 11-20
      • Bootstrap 21-31
    • Gear up for Success
    • jQuery
    • Basic Front End Development Projects
    • Basic JavaScript
      • Basic JavaScript 030
      • Basic JavaScript 060
      • Basic JavaScript 090
      • Basic JavaScript 101
    • Object Oriented and Functional Programming
    • Basic Algorithm Scripting
    • JSON APIs and Ajax
    • Intermediate Front End Development Projects
    • Intermediate Algorithm Scripting
Powered by GitBook
On this page

Was this helpful?

  1. Front End Development Certification
  2. HTML5 and CSS

HTML5 and CSS: 51-

51 - Override Class Declarations with Inline Styles

  • 用 in-line style

  • <h1 style="color: green">

  • in-line 的優先度比 id 屬性高

<style>
  body {
    background-color: black;
    font-family: Monospace;
    color: green;
  }
  #orange-text {
    color: orange;
  }
  .pink-text {
    color: pink;
  }
  .blue-text {
    color: blue;
  }
</style>
<h1 id="orange-text" class="pink-text blue-text" style="color: white">Hello World!</h1>

52 - Override All Other Styles by using Important

  • 你以為 inline 是覆蓋優先層級最高的嘛

  • 錯了,還有 !important

  • color: red !important;

<style>
  body {
    background-color: black;
    font-family: Monospace;
    color: green;
  }
  #orange-text {
    color: orange;
  }
  .pink-text {
    color: pink !important;
  }
  .blue-text {
    color: blue;
  }
</style>
<h1 id="orange-text" class="pink-text blue-text" style="color: white">Hello World!</h1>

53 - Use Hex Code for Specific Colors

  • hexadecimal code, hex code, 十六進位制

  • 6個hexadecimal digits 代表 color

<style>
  body {
    background-color: #000000;
  }
</style>

54 - Use Hex Code to Mix Colors

  • FF8080,#80FF80,#8080FF 意外的好看

Color

Hex Code

Dodger Blue

#2998E4

Green

#00FF00

Orange

#FFA500

Red

#FF0000

White

#FFFFFF

Black

#000000

Gray

#808080

55 - Use Abbreviated Hex Code

  • 可用簡碼,三碼

<style>
  .red-text {
    color: #F00;
  }
  .fuchsia-text {
    color: #F0F;
  }
  .cyan-text {
    color: #0FF;
  }
  .green-text {
    color: #0F0;
  }
</style>

<h1 class="red-text">I am red!</h1>

<h1 class="fuchsia-text">I am fuchsia!</h1>

<h1 class="cyan-text">I am cyan!</h1>

<h1 class="green-text">I am green!</h1>

56 - Use RGB values to Color Elements

  • RGB value

<style>
  body {
    background-color: rgb(0, 0, 0);
  }
</style>

57 - Use RGB to Mix Colors

  • Blue rgb(0, 0, 255)

  • Red rgb(255, 0, 0)

  • Orchid rgb(218, 112, 214)

  • Sienna rgb(160, 82, 45)

PreviousHTML5 and CSS: 41-50NextResponsive Design with Bootstrap

Last updated 5 years ago

Was this helpful?

Hexadecimal - Wikipedia
RGB color model - Wikipedia