06.颜色.html 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. <style>
  9. /*
  10. 颜色单位:
  11. 在CSS中可以直接使用颜色名来设置各种颜色
  12. 比如:red、orange、yellow、blue、green……
  13. 但是在CSS中直接使用颜色名是非常的不方便
  14. RGB值:
  15. -RGB实际上就是通过三种颜色的不同浓度来调配出不同的颜色
  16. -R red,G green,B blue
  17. -每一种颜色的范围在0-255(或者0%-100%)之间
  18. -语法:RGB(红色,绿色,蓝色)
  19. (光的三原色,它可以表示的颜色总数为255×255×255)
  20. RGBA:
  21. -就是在rgb的基础上增加了一个a表示不透明度
  22. -需要四个值:前三个和rgb一样,第四个表示不透明度
  23. 1表示完全不透明,0表示完全透明(相当于没有颜色),.5表示半透明
  24. 十六进制的RGB值
  25. -语法:#红色绿色蓝色
  26. -颜色浓度通过00-ff
  27. -如果颜色两位两位重复,可以进行简写
  28. 比如:#aabbcc --> #abc
  29. HSL值 HSLA值
  30. H 色相(取值范围是0~360)
  31. S 饱和度:颜色的浓度 0%-100%
  32. L 亮度:颜色的亮度 0%-100%
  33. */
  34. .box1{
  35. width: 100px;
  36. height: 100px;
  37. background-color: red;
  38. background-color: rgb(255,0,0,.5);
  39. background-color: rgb(0,255,0);
  40. background-color: rgb(0,0,255);
  41. background-color: rgb(0,0,0);
  42. background-color: rgb(255,255,255);
  43. background-color: rgb(106,153,85,.5);
  44. background-color: #ff0000;
  45. background-color: #ffff00;
  46. background-color: #ff0;
  47. background-color: hsl(360, 100%, 50%);
  48. }
  49. </style>
  50. </head>
  51. <body>
  52. <div class="box1"></div>
  53. </body>
  54. </html>