zoukankan      html  css  js  c++  java
  • 49.纯 CSS 创作一支诱人的冰棍

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

    感想:重点在让色彩滚动起来-》background-position: 0 1000vh; 

    HTML code:

    <div class="ice-lolly">
        <div class="flavors"></div>
        <div class="stick"></div>
    </div>

    CSS code:

    html, body {
        margin: 0;
        padding: 0;
    }
    body{
        height: 100vh;
        display: flex;
        justify-content: center;
        align-content: center;
        background-color: darkslategray;
    }
    .ice-lolly:hover .flavors::before{
        animation-play-state: running;
    }
    /* 绘制冰棍的外形 */
    .flavors{
        position: relative;
        width: 19em;
        height: 26em;
        font-size: 10px;
        border: 1px solid white;
        border-radius: 8em 8em 1em 1em;
        /* 溢出隐藏 */
        overflow: hidden;
    }
    /* 给冰棍上色 */
    .flavors::before{
        content: '';
        width: 140%;
        height: 120%;
        border: 1px solid blue;
        position: absolute;
        left: -20%;
        background: linear-gradient(
            hotpink 0%,
            hotpink 25%,
            deepskyblue 25%,
            deepskyblue 50%,
            gold 50%,
            gold 75%,
            lightgreen 75%,
            lightgreen 100%
        );
        z-index: -1;
        transform: rotate(-25deg);
        animation: moving 100s linear infinite;
        animation-play-state: paused;
    }
    @keyframes moving{
        to{
            background-position: 0 1000vh;
        }   
    }
    /* 来一点光照效果 */
    .flavors::after{
        content: '';
        width: 2em;
        height: 17em;
        border-radius: 1em;
        position: absolute;
        left: 2em;
        bottom: 2em;
        background-color: rgba(255, 255, 255, 0.4);   
    }
    /* 画出冰棍筷子 */
    .stick{
        position: relative;
        width: 6em;
        height: 10em;
        left: calc(50% - 6em / 2);
        border-radius: 0 0 3em 3em;
        background-color: sandybrown;
    }
    /* 给冰棍筷子加一点阴影,增加立体感 */
    .stick::after{
        content: '';
        width: inherit;
        height: 2.5em;
        position: absolute;
        background-color: sienna;
    }
  • 相关阅读:
    我的黑客偶像
    2020-2021-1学期 学号20201222 《信息安全专业导论》第5周学习总结
    XOR加密
    pep/9
    我的黑客偶像
    学年2020-2021,1 学号:20201222《信息安全专业导论》第4周学习总结”
    IEEE754浮点数转换
    师生关系
    罗马数字转阿拉伯数字
    第三周总结
  • 原文地址:https://www.cnblogs.com/FlyingLiao/p/10475597.html
Copyright © 2011-2022 走看看