使用css3怎么實現(xiàn)一個寵物小雞

今天就跟大家聊聊有關(guān)使用css3怎么實現(xiàn)一個寵物小雞,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。

在沂源等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供成都網(wǎng)站設(shè)計、成都網(wǎng)站建設(shè) 網(wǎng)站設(shè)計制作按需定制網(wǎng)站,公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),成都品牌網(wǎng)站建設(shè),營銷型網(wǎng)站,外貿(mào)營銷網(wǎng)站建設(shè),沂源網(wǎng)站建設(shè)費用合理。

<body>
    <div class="content">
        <!-- 天上的云 -->
        <div class="cloud">
            <div class="content"></div>
        </div>
        <!--雞冠-->
        <div class="crest"></div>
        <!--翅膀-->
        <div class="hand"></div>
        <!-- 寵物小雞body -->
        <div class="egg">
            <!--眼睛-->
            <div class="eye"></div>
            <!--腮紅-->
            <div class="blush"></div>
            <!--嘴-->
            <div class="mouth"></div>
            <!--腳-->
            <div class="feet"></div>
        </div>

    </div>
</body>

接下來是css設(shè)置樣式:

先設(shè)置整體的背景色,使用的是線性漸變linear-gradient,設(shè)置藍天色和草地色,并設(shè)置讓元素居中。

.content {
        width: 100%;
        height: 800px;
        background: linear-gradient(rgb(170, 227, 253) 60%, rgb(149, 219, 126) 80px);
        display: flex;
        justify-content: center;
        align-items: center;
        }

天上的云:先給一定的寬高和背景色,使用border-radius設(shè)置邊框圓角效果,只設(shè)置左上和右上。效果如下:

 border-radius: 100% 100% 0 0;

使用css3怎么實現(xiàn)一個寵物小雞

在使用::before和::after偽元素畫出一朵完整的云:

.content::before,
 .content::after {
                content: '';
                position: absolute;
                bottom: 0;
            }
  .content::before {
                width: 40px;
                height: 40px;
                background: currentColor;
                left: -20px;
                border-radius: 100% 100% 0 100%;
            }
   .content::after {
                width: 35px;
                height: 30px;
                background: currentColor;
                right: -20px;
                border-radius: 100% 100% 100% 0;
            }

然后使用陰影在畫出兩朵云

使用css3怎么實現(xiàn)一個寵物小雞

.content,
.content::before,
.content::after {
                box-shadow: 
                -200px 50px 0 -5px rgb(191, 232, 252),
                 200px 60px 0 10px rgb(191, 233, 253);
            }

使用css3怎么實現(xiàn)一個寵物小雞

云朵實現(xiàn)了。

接下來是寵物小雞,先把身體寫出來,同樣用border-radius設(shè)置邊框圓角效果,畫出雞蛋的模樣,設(shè)置背景色,并使用box-shadow設(shè)置向內(nèi)的陰影。

.egg {
            width: 220px;
            height: 260px;
            border-radius: 100%;
            background: linear-gradient(rgb(254, 249, 249) 60%,rgb(221, 213, 213));
            position: absolute;
            display: flex;
            flex-direction: column;
            align-items: center;
            box-shadow: 0 -10px 10px 3px rgba(211, 194, 194,0.4) inset;
}

使用css3怎么實現(xiàn)一個寵物小雞

雞冠和云朵的寫法差不多

.crest {
            position: relative;
            top: -17%;
            width: 30px;
            height: 25px;
            background: rgb(233, 19, 19);
            border-radius: 50% 100% 20% 20%;
        }
  .crest::before,
  .crest::after {
            content: '';
            position: absolute;
            bottom: 0; 
            width: 20px; 
            background: rgb(233, 19, 19);
        }
  .crest::before {
            left: -5px;
            height: 20px;
            border-radius: 100% 50% 0 20%;
        }
  .crest::after {
            right: -15px;
            height: 15px;
            background: rgb(233, 19, 19);
            border-radius: 20% 200% 20% 30%;
        }

眼睛,翅膀,腮紅,分別用偽元素左右定位設(shè)置大小即可實現(xiàn)。嘴部使用transform旋轉(zhuǎn)45&deg;并使用線性漸變設(shè)置雞嘴的陰影效果。

全部css代碼如下(我安裝了sass插件,所以是scss的寫法):

body {
    margin: 0;
    width: 100%;
    height: 100%;
    >.content {
        width: 100%;
        height: 800px;
        background: linear-gradient(rgb(170, 227, 253) 60%, rgb(149, 219, 126) 80px);
        display: flex;
        justify-content: center;
        align-items: center;
        >.cloud {
            position: absolute;
            top: 5%;
            color: rgb(216, 242, 254);
            >.content {
                width: 50px;
                height: 50px;
                background: currentColor;
                border-radius: 100% 100% 0 0;
            }
            >.content::before,
            >.content::after {
                content: '';
                position: absolute;
                bottom: 0;
            }
            >.content::before {
                width: 40px;
                height: 40px;
                background: currentColor;
                left: -20px;
                border-radius: 100% 100% 0 100%;
            }
            >.content::after {
                width: 35px;
                height: 30px;
                background: currentColor;
                right: -20px;
                border-radius: 100% 100% 100% 0;
            } 
            >.content,
            .content::before,
            .content::after {
                box-shadow: -200px 50px 0 -5px rgb(191, 232, 252),
                             200px 60px 0 10px rgb(191, 233, 253);
            }
        }
        >.egg {
            width: 220px;
            height: 260px;
            border-radius: 100%;
            background: linear-gradient(rgb(254, 249, 249) 60%,rgb(221, 213, 213));
            position: absolute;
            display: flex;
            flex-direction: column;
            align-items: center;
            box-shadow: 0 -10px 10px 3px rgba(211, 194, 194,0.4) inset;
            >.eye::before,
            .eye::after {
                content: '';
                position: absolute;
                top: 15%;
                width: 12px;
                height: 28px;
                border-radius: 100%;
                background: radial-gradient(white 1px, rgb(57, 56, 57) 5%);
            }
            > .eye::before{
                left: 28%;
            }
            >.eye::after {
                right: 28%;
            }
            >.blush::before,
            .blush::after {
                content: '';
                position: absolute;
                top: 30%;
                width: 25px; 
                height: 5px;
                transform: rotate(0deg); 
                background: rgb(250, 108, 127);
                border-radius: 100%;
                box-shadow: 0 0 5px 4px rgb(250, 108, 127);
            }
            >.blush::before {
                left: 20%;
            }
            >.blush::after {
                right: 20%;
            }
            >.mouth {
                position: absolute;
                top: 32%;
                width: 20px;
                height: 20px;
                background: 
                    linear-gradient(135deg, rgb(255, 207, 0) 50%, 
                    rgb(224, 184, 2) 50%);
                transform: rotate(45deg);
                border-radius: 5% 15%;
            }
            > .feet::before,
            .feet::after{
                content: '';
                position: absolute; 
                bottom: -12px;
                width: 10px;
                height: 15px;
                border: 7px solid rgb(71, 49, 20);
            }
            > .feet::before{
                left: 60px;
                border-radius: 80% 100% 100% 50%;
                transform: rotate(-10deg);
                border-color: transparent  transparent transparent rgb(71, 49, 20);
            }
            > .feet::after{
                right: 60px;
                border-radius: 100% 80% 50% 0%;
                transform: rotate(10deg);
                border-color: transparent rgb(71, 49, 20) transparent transparent ;
            } 
        }
        >.crest {
            position: relative;
            top: -17%;
            width: 30px;
            height: 25px;
            background: rgb(233, 19, 19);
            border-radius: 50% 100% 20% 20%;
        }
        >.crest::before,
        .crest::after {
            content: '';
            position: absolute;
            bottom: 0; 
            width: 20px; 
            background: rgb(233, 19, 19);
        }
        >.crest::before {
            left: -5px;
            height: 20px;
            border-radius: 100% 50% 0 20%;
        }
        >.crest::after {
            right: -15px;
            height: 15px;
            background: rgb(233, 19, 19);
            border-radius: 20% 200% 20% 30%;
        }
        > .hand{
            position: relative;
            top: -5%;
        }
        > .hand::before,
        .hand::after{
            content: '';
            position: absolute;
        }
        > .hand::before{
            left:-135px;
            width: 20px;
            height: 80px;
            transform: rotate(15deg);
            background: rgb(250, 242, 242);
            border-radius: 100% 0 50% 50%;
        }
        > .hand::after{
            right: -110px;
            width: 20px;
            height: 80px;
            transform: rotate(-15deg);
            background: rgb(250,242,242);
            border-radius: 50% 100% 50% 50%;
        }
    }
}

看完上述內(nèi)容,你們對使用css3怎么實現(xiàn)一個寵物小雞有進一步的了解嗎?如果還想了解更多知識或者相關(guān)內(nèi)容,請關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝大家的支持。

本文題目:使用css3怎么實現(xiàn)一個寵物小雞
鏈接分享:http://www.muchs.cn/article46/ishjeg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供域名注冊定制開發(fā)、網(wǎng)站建設(shè)自適應(yīng)網(wǎng)站、外貿(mào)網(wǎng)站建設(shè)、品牌網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

搜索引擎優(yōu)化