當(dāng)前位置:首頁 > IT技術(shù) > Web編程 > 正文

css分別實現(xiàn)直線,三角形以及瀏覽器上下左右居中
2021-09-13 15:50:31

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        html,body {
            position: relative;
            width: 100%;
            height:100%;
        }
        .triangle {
            width: 0px;
            height:0px;
            border-bottom: 200px solid #00a3af;
            border-left: 200px solid transparent;
            border-right: 200px solid transparent;
        }
        .hr {
            margin-top: 500px;
            border: 1px solid #00a3af;
            transform: scaleY(0.5);
        }
        .clign {
            position: absolute;
            left: 0;
            right:0;
            top: 0;
            bottom:0;
            width: 200px;
            height: 200px;
            background-color: bisque;
            margin: auto;
        }
    </style>
</head>
<body>
    <div class='triangle'></div>

    <div class="hr"></div>

    <div class='clign'></div>
</body>
</html>

?顯示效果如下所示:

?

本文摘自 :https://www.cnblogs.com/

開通會員,享受整站包年服務(wù)立即開通 >