用CSS画个三角形

<!DOCTYPE html>
<html>
<head>
    <style type="text/css">
        #trangle {
            display: inline-block;
            width: 200px;
            height: 200px;
            border-left: 100px solid #333;
            border-right: 100px solid #678;
            border-top: 100px solid #91b;
            border-bottom: 100px solid #eee;
        }
    </style>
</head>
<body>
    <span id="trangle"></span>
</body>
</html>

 

 

<!DOCTYPE html>
<html>
<head>
    <style type="text/css">
        #trangle {
            display: inline-block;
            border-left: 100px solid #333;
            border-right: 100px solid #678;
            border-top: 100px solid #91b;
        }
    </style>
</head>
<body>
    <span id="trangle"></span>
</body>
</html>

<!DOCTYPE html>
<html>
<head>
    <style type="text/css">
        #trangle {
            display: inline-block;
            border-left: 100px solid transparent;
            border-right: 100px solid transparent;
            border-top: 100px solid #91b;
        }
    </style>
</head>
<body>
    <span id="trangle"></span>
</body>
</html>

把两边设置transparent透明就可以l,利用border的特性

 

posted @ 2016-05-28 13:41  xnuwu  阅读(228)  评论(0编辑  收藏  举报