HTML_CSS学习:CSS像素与颜色

一、像素

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>像素</title>
</head>
    <style>
        .atguigu1{
            /*单位可以是cm,但不能是m,dm*/
            width: 1cm;
            height: 1cm;
            background-color: #f73131;
        }
        .atguigu2{
            /*单位可以是cm、mm,但不能是m,dm*/
            width: 1mm;
            height: 1mm;
            background-color: #f73131;
        }
        .atguigu3{
            /*单位可以是cm、,但不能是m,dm*/
            width: 100px;
            height: 100px;
            background-color: #f73131;
        }

    </style>
<body>
    <div class="atguigu1"></div>
    <br>
    <div class="atguigu2"></div>
    <br>
    <div class="atguigu3"></div>

</body>
</html>

二、颜色_第一种表示_颜色名

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>颜色名</title>
    <style>
        .atguigu{
            color: blue;
        }
    </style>
</head>
<body>
    <h2 class="atguigu">尚硅谷</h2>

</body>
</html>

三、颜色_第二种表示_rgb或rgba

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>rgb和rgba表示</title>
    <style>
        .atguigu1{
            color: rgb(255,0,0);
        }
        .atguigu2{
            color: rgb(0,255,0);
        }
        .atguigu3{
            color: rgb(0,0,255);
        }
        .atguigu4{
            color: rgb(133,43,226);
        }
        .atguigu5{
            color: rgb(100%,0%,0%);
        }
        .atguigu6{
            color: rgba(255,0,0,0.5);
        }
        .atguigu7{
            color: rgb(50,50,50);
        }
    </style>
</head>
<body>
    <h2 class="atguigu1">尚硅谷1</h2>
    <h2 class="atguigu2">尚硅谷2</h2>
    <h2 class="atguigu3">尚硅谷3</h2>
    <h2 class="atguigu4">尚硅谷4</h2>
    <h2 class="atguigu5">尚硅谷5</h2>
    <h2 class="atguigu6">尚硅谷6</h2>
    <h2 class="atguigu7">尚硅谷7</h2>

</body>
</html>

四、颜色_第三种表示_HEX或HEXA

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>HEX或HEXA</title>
</head>
    <style>
        .atguigu1{
            /*#color: #第一组第二组第三组;没两位一组,16进制*/
            color: #af17bf;
        }
        .atguigu2{
            /*#color: #第一组第二组第三组;没两位一组,16进制*/
            color: #7fbf17;
        }
        .atguigu3{
            /*#color: #第一组第二组第三组;没两位一组,16进制*/
            color: #be9b29;
        }
        .atguigu4{
            /*#color: #第一组第二组第三组;没两位一组,16进制*/
            color: #c7edcc;
        }
        .atguigu5{
            /*#color: #第一组第二组第三组;没两位一组,16进制*/
            color: #87ceebff;
            /*带有透明度*/
        }
        /*HEXA是8位最后1两位是透明度*/
    </style>
<body>
    <h2 class="atguigu1">尚硅谷1</h2>
    <h2 class="atguigu2">尚硅谷2</h2>
    <h2 class="atguigu3">尚硅谷3</h2>
    <h2 class="atguigu4">尚硅谷4</h2>
    <h2 class="atguigu5">尚硅谷5</h2>

</body>
</html>

五、颜色_第五种表示_HSL或HSAL

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>HSL或HSLA</title>
    <style>
        .atguigu1{
            /*color: hsl(色相,饱和度,亮度);*/
            color:hsl(0, 100%, 50%);
        }
        .atguigu2{
            /*color: hsl(色相,饱和度,亮度);*/
            color:hsl(60, 100%, 50%);
        }
        .atguigu3{
            /*color: hsl(色相,饱和度,亮度);*/
            color:hsl(120, 100%, 50%);
        }
        .atguigu4{
            /*color: hsl(色相,饱和度,亮度);*/
            color:hsl(180, 100%, 50%);
        }
        .atguigu5{
            /*color: hsl(色相,饱和度,亮度);*/
            color:hsl(240, 100%, 50%);
        }
        .atguigu6{
            /*color: hsl(色相,饱和度,亮度);*/
            color:hsl(300, 100%, 50%);
        .atguigu7{
            /*color: hsl(色相,饱和度,亮度);*/
            color:rgba(300, 100%, 50%, 0.55);
        }
    </style>
</head>
<body>
    <h2 class="atguigu1">尚硅谷1</h2>
    <h2 class="atguigu2">尚硅谷2</h2>
    <h2 class="atguigu3">尚硅谷3</h2>
    <h2 class="atguigu4">尚硅谷4</h2>
    <h2 class="atguigu5">尚硅谷5</h2>
    <h2 class="atguigu6">尚硅谷6</h2>
    <h2 class="atguigu7">尚硅谷7</h2>

</body>
</html>

相关推荐

  1. HTML_CSS学习CSS颜色

    2024-05-02 05:56:03       14 阅读
  2. opencv改变点的颜色---------c++

    2024-05-02 05:56:03       16 阅读
  3. 【Tools】理解图像矩阵

    2024-05-02 05:56:03       7 阅读
  4. 关于图像opencv行列关系

    2024-05-02 05:56:03       47 阅读
  5. 什么是图片的分辨率?

    2024-05-02 05:56:03       8 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-05-02 05:56:03       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-05-02 05:56:03       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-05-02 05:56:03       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-05-02 05:56:03       18 阅读

热门阅读

  1. C++中的指针详解

    2024-05-02 05:56:03       9 阅读
  2. iOS 获取到scrollView停止拖动时候的速度

    2024-05-02 05:56:03       9 阅读
  3. Linux内核常用调优参数

    2024-05-02 05:56:03       8 阅读
  4. 移动应用开发:Android vs iOS平台的选择与挑战

    2024-05-02 05:56:03       6 阅读
  5. 【C++之二叉搜索树】

    2024-05-02 05:56:03       13 阅读
  6. nginx配置tcp长连接实现集群

    2024-05-02 05:56:03       11 阅读
  7. Android UI:动画:视图动画

    2024-05-02 05:56:03       12 阅读
  8. 力扣501,二叉树中的众数

    2024-05-02 05:56:03       10 阅读
  9. CocoaPods:iOS项目依赖管理的利器

    2024-05-02 05:56:03       9 阅读
  10. 【刷爆力扣之637. 二叉树的层平均值】

    2024-05-02 05:56:03       10 阅读
  11. 2.DNS同时使用TCP和UDP协议?

    2024-05-02 05:56:03       10 阅读