javascript - CSS绘制两个相连的多边形
大家讲道理
大家讲道理 2017-04-11 12:03:44
[JavaScript讨论组]

有这样一段HTML:

RepoBranch

想要用css绘制出下图的效果:

应该如何写这段CSS?

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

全部回复(2)
巴扎黑

大概是这么个意思,楼主你看一下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .shape {
            margin-left: -100px;
        }

        .shape:first-child {
            margin-left: 0;
        }

        .shape span {
            display: inline-block;
            line-height: 100px;
            width: 220px;
            background: #3abf28;
            vertical-align: top;
            color: white;
            font-size: 40px;
            font-family: Arial;
            text-align: center;
        }

        .shape:before {
            display: inline-block;
            content: "";
            border-left: 50px solid rgba(0, 0, 0, 0);
            border-top: 50px solid #3abf28;
            border-bottom: 50px solid #3abf28;
        }

        .shape:after {
            display: inline-block;
            content: "";
            border-left: 50px solid #3abf28;
            border-top: 50px solid rgba(0, 0, 0, 0);
            border-bottom: 50px solid rgba(0, 0, 0, 0);
            border-right: 50px solid rgba(0, 0, 0, 0);
        }
    </style>
</head>
<body>
    <p><span class="shape"><span>Repo</span></span></p>
</body>
</html>

迷茫

左侧的三角用before,右侧的三角用after

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号