28.纯 CSS 绘制一个世界上不存在的彭罗斯三角形

原文地址:https://segmentfault.com/a/1190000014946883

感想:三个平面图形旋转

HTML代码:

<!-- penrose: 彭罗斯 -->
<div class="penrose">
    <span></span>
    <span></span>
    <span></span>
</div>

CSS代码:

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: black;
}
/* 定位容器尺寸 */
.penrose{
    position: relative;
    width: 20em;
    height: 20em;
    color: red;
    animation: rotating 30s linear infinite;
    transform-origin: 66% 66%;
}
@keyframes rotating {
    0% {
        color: red;
        transform: rotate(0deg);
    }

    20% {
        color: yellow;
    }

    40% {
        color: lime;
    }

    60% {
        color: blue;
    }

    80% {
        color: fuchsia;
    }

    100% {
        color: red;
        transform: rotate(720deg);
    }
}
.penrose span {
    position: absolute;
    width: 100%;
    height: 100%;
    /* currentColor: 当前颜色 */
    background-color: currentColor;
    /* 用遮罩切出每一条边,组成彭罗斯三角形 */
    clip-path: polygon(57% 0, 75% 0, 26% 85%, 89.5% 85%, 98.4% 100%, 0 100%);
}

.penrose span:nth-child(1) {
    /* 过滤器 亮度1 */
    filter: brightness(1);
    transform: rotate(0deg);
}
.penrose span:nth-child(2) {
    top: 18.3%;
    left: 43.3%;
    filter: brightness(0.66);
    transform: rotate(120deg);
}
.penrose span:nth-child(3) {
    top: 46.5%;
    left: 5.9%;
    filter: brightness(0.33);
    transform: rotate(240deg);
}

 

posted on 2019-01-23 20:15  人生与戏 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/FlyingLiao/p/10311186.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值