16-CSS边框圆角和渐变

2018-10-29  本文已影响0人  喝酸奶要舔盖__

边框圆角属性

绘制椭圆

<style>
        div {
            width: 300px;
            height: 100px;
            border: 1px solid #000;
            margin: 100px auto;
            background-color: red;
            /*绘制椭圆水平方向为盒子宽度的一半,垂直方向为盒子高度的一半*/
            /*border-radius: 150px / 50px;*/
            border-radius: 50%;
        }
    </style>

绘制半圆

<style>
        div{
            width: 400px;
            height: 200px;
            background-color: green;
            /*绘制上半圆*/
            /*border-top-left-radius: 200px;*/
            /*border-top-right-radius: 200px;*/
            /*绘制下半圆*/
            border-bottom-left-radius: 200px;
            border-bottom-right-radius: 200px;
        }
    </style>

绘制圆环

<style>
        div{
            width: 300px;
            height: 300px;
            margin: 100px auto;
            border: 100px solid #000;
            /*border-radius: 50%;*/
            border-radius: 150px;
            box-sizing: border-box;
        }
    </style>

线性渐变

background: linear-gradient(to left,yellow,red,rebeccapurple);
background: linear-gradient(45deg,green,red,blue);
background: linear-gradient(to right, red 100px,green 150px, yellow 200px);

径向渐变

background: radial-gradient(red,rebeccapurple);
指定渐变中心点
background: radial-gradient(at top left,green, rebeccapurple);
渐变中心点接收像素
background: radial-gradient(at 100px 100px,green,yellow);
background: radial-gradient(100px,greenyellow,blue);
同时指定渐变范围和渐变中心位置
background: radial-gradient(200px at top left,green,mediumpurple);
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        body{
            background-color: #000000;
        }
        div{
            width: 600px;
            height: 100px;
            border: 1px solid lavender;
            margin: 100px auto;
            font-size: 80px;
            text-align: center;
            line-height: 100px;
            font-weight: bold;
            color: rgba(255,255,255,.3);
            background-image: linear-gradient(-30deg, transparent 30px, white 60px, white 120px, transparent 150px);
            background-position: -450px 0;
            background-repeat: no-repeat;

            -webkit-background-clip: text;
            /*transition-property: background-position;
            transition-duration: 3s;
            transition-timing-function: linear;*/
            transition: background-position 2s linear;
        }

        div:hover{
            background-position: 400px 0;
        }
    </style>
</head>
<body>
<div>IG加油加油!</div>
</body>
</html>
上一篇 下一篇

猜你喜欢

热点阅读