css的linear-gradient注意点

2020-10-28 10:31:21 浏览数 (1)

代码语言:javascript复制
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>127-线性渐变</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .main{
            width: 400px;
            height: 200px;
            border: 1px solid #000;
            box-sizing: border-box;
            margin: 200px auto;
            /*
            注意点:
            至少需要传递2个颜色, 至多没有上限
            */
            
            */
            background: linear-gradient(to right, red 100px, green 100px, blue 100px);
        }
        .one, .two, .three{
            width: 100px;
            height: 100%;
            border: 1px solid #000;
            box-sizing: border-box;
            float: left;
        }
    </style>
</head>
<body>
<div class="main">
    <div class="one"></div>
    <div class="two"></div>
    <div class="three"></div>
</div>
</body>
</html>

0 人点赞