div+css3绘制六边形

效果图如下:
在这里插入图片描述

代码实现如下:

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>CSS3 实现六边形图片展示效果</title>
    <style type="text/css">
        body, div, img, ul, li
        {
            margin: 0;
            padding: 0;
        }
        body
        {
            font-size: 12px;
            background-color: #DDD;
            min-width: 1200px;
        }
        ul, ul li
        {
            list-style: none;
        }
        .clear
        {
            clear: both;
        }       
        .box
        {
            position: relative;
            width: 630px;
            margin: 100px auto;
        }
        .box-top, .box-bottom
        {
            position: absolute;
            visibility: hidden;
        }
        .box-bottom
        {
            top: 182px;
            left: 105px;
        }
        .box1, .box2, .box3, .box4
        {
            width: 200px;
            height: 250px;
            overflow: hidden;
        }
        .box1, .box2
        {
            visibility: hidden;
        }
        .box1
        {
            transform: rotate(120deg);
            float: left;
            margin-left: 10px;
            -ms-transform: rotate(120deg);
            -moz-transform: rotate(120deg);
            -webkit-transform: rotate(120deg);
        }
        .box2
        {
            transform: rotate(-60deg);
            -ms-transform: rotate(-60deg);
            -moz-transform: rotate(-60deg);
            -webkit-transform: rotate(-60deg);
        }
        .box3
        {
            transform: rotate(-60deg);
            background: no-repeat 50% center;
            background-size: 125% auto;
            -ms-transform: rotate(-60deg);
            -moz-transform: rotate(-60deg);
            -webkit-transform: rotate(-60deg);
            visibility: visible;
            background: pink;
            box-shadow: #BF0060 2px 15px 75px 7px inset;
        }
        .box4
        {
            display: block;
            position: relative;
        }
        .box4 a
        {
            display: inline-block;
            position: absolute;
            left: 50%;
            top: 50%;
            margin: -16px 0 0 -16px;
            border-radius: 3px;
            text-align: center;
            line-height: 32px;
            width: 32px;
            height: 32px;
            text-decoration: none;
            color: White;
            font-size: 18px;
            font-weight: bolder;
        }
    </style>
</head>
<body>
    <div class="box">
        <div class="box-top">
            <div class="box1">
                <div class="box2">
                    <div class="box3">
                        <div class="box4">
                            <a href="#">+</a>
                        </div>
                    </div>
                </div>
            </div>
            <div class="box1">
                <div class="box2">
                    <div class="box3">
                        <div class="box4">
                            <a href="#">+</a>
                        </div>
                    </div>
                </div>
            </div>
            <div class="box1">
                <div class="box2">
                    <div class="box3">
                        <div class="box4">
                            <a href="#">+</a>
                        </div>
                    </div>
                </div>
            </div>

        </div>
        <div class="box-bottom">
            <div class="box1">
                <div class="box2">
                    <div class="box3">
                        <div class="box4">
                            <a href="#">+</a>
                        </div>
                    </div>
                </div>
            </div>
            <div class="box1">
                <div class="box2">
                    <div class="box3">
                        <div class="box4">
                            <a href="#">+</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

</body>
</html>

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值