zoukankan      html  css  js  c++  java
  • 62.纯 CSS 创作一只蒸锅(感觉不好看呀)

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

    HTML code:

    <!-- steamer: 蒸锅; lid: 盖子; pot: 锅 -->
    <div class="steamer">
         <div class="lid"></div>
         <div class="pot"></div>
    </div>

    CSS code:

    html, body {
        margin: 0;
        padding: 0;
    }
    body {
        height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
        background: linear-gradient(to right bottom, violet, midnightblue);
    }
    /* 定义.steamer容器尺寸 */
    .steamer {
        font-size: 10px;
        width: 30em;
        height: 30em;
        border-radius: 50%;
      /* border: 1px solid white;*/ 
        background-color: snow;
        /* 设置.steamer中的元素水平垂直居中而且是垂直排列 */
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        
        z-index: 1;
    }
    /* 画出锅(底座) */
    .pot {
        position: relative;
        width: 16em;
        height: 12em;
        background: darkslateblue;
        border-radius: 0.5em 0.5em 6.5em 6.5em;
        /* 右边框造出的阴影 */
        border-right: 1.5em solid midnightblue;
    }
    /* 画出锅把手 */
    .pot::before {
        content: '';
        width: 27em;
        height: 2.5em;
        background-color: tomato;
        position: absolute;
        left: -4.75em;
        top: 2em;
        z-index: -1;
    }
    /* 为锅体增加光影 */
    .pot::after {
        content: '';
        position: absolute;
        width: 8em;
        height: 8em;
        border: 0.6em solid transparent;
        border-radius: 50%;
        border-left-color: white;
        transform: rotate(-60deg);
        top: 1em;
        left: 2em;
    }
    /* 画出锅盖 */
    .lid {
        width: 17em;
        height: 6em;
        background-color: gold;
        position: relative;
        border-radius: 6em 6em 0 0;
        border-right: 1.5em solid goldenrod;
        /* 动画效果 */
        transform: translateY(-0.5em);
        animation: animate 1s infinite alternate;
    }
    @keyframes animate{
        to{
            transform: translateY(0.5em);
        }
    }
    /* 画出锅盖上的钮扣把手 */
    .lid::before {
        content: '';
        position: absolute;
        width: 4em;
        height: 4em;
        background-color: tomato;
        border-radius: 50%;
        left: 7em;
        top: -2.5em;
    }
    /* 为锅盖增加光影 */
    .lid::after {
        content: '';
        position: absolute;
        width: 7em;
        height: 7em;
        border: 0.6em solid transparent;
        border-radius: 50%;
        border-left-color: white;
        transform: rotate(40deg);
        top: 0.6em;
        left: 2.5em;
    }
  • 相关阅读:
    个人总结
    第三次个人作业
    第二次结对作业
    第一次结对作业
    第二次个人编程作业
    第一次博客编程作业
    第一次随笔作业
    BUAA_2020_软件工程_提问回顾与总结
    BUAA_2020_软件工程_软件案例分析作业
    BUAA_2020_软件工程_结对项目作业
  • 原文地址:https://www.cnblogs.com/FlyingLiao/p/10653655.html
Copyright © 2011-2022 走看看