CSS 之颜色(Color)

一、属性

Properties
属性
Description
简介
color 指定颜色。请参阅颜色值
opacity 检索或设置对象的不透明度。

二、示例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        h1 {
            margin: 10px 0;
            font-size: 16px;
        }

        .test {
            width: 300px;
            height: 150px;
            padding: 10px;
            background: #050;
        }

        .test2 {
            width: 300px;
            height: 150px;
            margin: -120px 0 0 50px;
            padding: 10px;
            background: #000;
            filter: alpha(opacity=50);
            opacity: .5;
            color: #fff;
        }
    </style>
</head>
<body>
<h1>下例是一个半透明的效果:</h1>
<div class="test">不透明度为100%的box</div>
<div class="test2">不透明度为50%的box</div>
</body>
</html>

posted @ 2019-12-13 16:47  样子2018  阅读(393)  评论(0编辑  收藏  举报