• <fieldset id="8imwq"><menu id="8imwq"></menu></fieldset>
  • <bdo id="8imwq"><input id="8imwq"></input></bdo>
    最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
    問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
    當前位置: 首頁 - 科技 - 知識百科 - 正文

    如何使用CSS的Grid布局實現小狗郵票(附源碼)

    來源:懂視網 責編:小采 時間:2020-11-02 22:08:32
    文檔

    如何使用CSS的Grid布局實現小狗郵票(附源碼)

    如何使用CSS的Grid布局實現小狗郵票(附源碼):本篇文章給大家帶來的內容是關于如何使用CSS的Grid布局實現小狗郵票(附源碼),有一定的參考價值,有需要的朋友可以參考一下,希望對你有所幫助。效果預覽源代碼下載https://github.com/comehope/front-end-daily-challenges代碼解讀定義 d
    推薦度:
    導讀如何使用CSS的Grid布局實現小狗郵票(附源碼):本篇文章給大家帶來的內容是關于如何使用CSS的Grid布局實現小狗郵票(附源碼),有一定的參考價值,有需要的朋友可以參考一下,希望對你有所幫助。效果預覽源代碼下載https://github.com/comehope/front-end-daily-challenges代碼解讀定義 d
    本篇文章給大家帶來的內容是關于如何使用CSS的Grid布局實現小狗郵票(附源碼),有一定的參考價值,有需要的朋友可以參考一下,希望對你有所幫助。

    效果預覽

    1958362444-5ba9a3d852436_articlex.png

    源代碼下載

    https://github.com/comehope/front-end-daily-challenges

    代碼解讀

    定義 dom,容器表示郵票:

    <div class="stamp">
    </div>

    居中顯示:

    body {
     margin: 0;
     height: 100vh;
     display: flex;
     align-items: center;
     justify-content: center;
     background-color: teal;
    }

    設置容器尺寸:

    .stamp {
     position: relative;
     width: 40.5em;
     height: 71em;
     font-size: 6px;
     padding: 5em;
     background-color: white;
    }

    用重復背景繪制出郵票的齒孔:

    .stamp {
     display: flex;
     flex-direction: column;
     align-items: center;
     justify-content: center;
    }
    
    .stamp::after,
    .stamp::before {
     content: '';
     width: 100%;
     height: 100%;
     position: absolute;
     background: radial-gradient(circle, teal 50%, transparent 50%),
     radial-gradient(circle, teal 50%, transparent 50%);
     background-size: 3.5em 3.5em;
    }
    
    .stamp::before {
     top: 1.5em;
     background-repeat: repeat-y;
     background-position: -4.5% 0, 104.5% 0;
    }
    
    .stamp::after {
     left: 1.5em;
     background-repeat: repeat-x;
     background-position: 0 -2.5%, 0 102.5%;
    }

    在 html 文件中增加小狗的 dom 元素,子元素分別表示耳朵、頭部、眼睛、舌頭、身體、尾巴和爪子:

    <div class="stamp">
     <div class="puppy">
     <span class="ear"></span>
     <span class="head"></span>
     <span class="eyes"></span>
     <span class="tongue"></span>
     <span class="body"></span>
     <span class="tail"></span>
     <span class="foot"></span>
     </div>
    </div>

    設置 grid 布局的行列尺寸:

    .puppy {
     display: grid;
     grid-template-columns: 10em 22.5em 8em;
     grid-template-rows: 21em 12.5em 3.75em 22.5em;
     background-color: tan;
     padding: 2em;
     margin-top: -1em;
    }

    畫出小狗的頭部,跨第1列和第2列、第2行和第3行,是一個半圓形:

    .head {
     grid-column: 1 / 3;
     grid-row: 2 / 4;
     border-bottom-left-radius: calc(12.5em + 3.75em);
     border-bottom-right-radius: calc(12.5em + 3.75em);
     background-color: bisque;
    }

    用偽元素畫出鼻子,是一個扇形,多余的部分被隱藏了:

    .head {
     position: relative;
     overflow: hidden;
    }
    
    .head::before {
     content: '';
     position: absolute;
     width: 7em;
     height: 7em;
     border-bottom-right-radius: 100%;
     background-color: sienna;
    }

    畫出半圓形的眼暈:

    .eyes {
     grid-column: 2;
     grid-row: 2;
     justify-self: end;
     position: relative;
     height: 10.5em;
     width: 21em;
     border-radius: 0 0 10.5em 10.5em;
     background-color: sienna;
    }

    用徑向漸變畫出眼珠:

    .eyes {
     background-image: radial-gradient(
     circle at 37% 33%,
     black 1.4em,
     transparent 1.4em
     );
    }

    畫出半圓形的耳朵:

    .ear {
     grid-column: 2;
     grid-row: 1;
     justify-self: end;
     width: 10.5em;
     border-radius: 21em 0 0 21em;
     background-color: sienna;
    }

    畫出扇形的舌頭:

    .tongue {
     grid-column: 1;
     grid-row: 3;
     width: 5.5em;
     height: 5.5em;
     background-color: indianred;
     border-bottom-left-radius: 100%;
    }

    畫出扇形的身體:

    .body {
     grid-column: 2;
     grid-row: 4;
     background-color: sienna;
     border-top-left-radius: 100%;
    }

    用偽元素,通過陰影畫出中蹲著的腿:

    .body {
     position: relative;
     overflow: hidden;
    }
    
    .body::after {
     content: '';
     position: absolute;
     height: 50%;
     width: 100%;
     border-radius: 11.25em 11.25em 0 0;
     box-shadow: 2em 0 4em rgba(0, 0, 0, 0.3);
     bottom: 0;
    }

    畫出半圓形的尾巴:

    .tail {
     grid-column: 1;
     grid-row: 4;
     justify-self: end;
     align-self: end;
     height: 17.5em;
     width: 8.75em;
     background-color: bisque;
     border-radius: 17.5em 0 0 17.5em;
    }

    畫出半圓形的小爪子:

    .foot {
     grid-column: 3;
     grid-row: 4;
     align-self: end;
     height: 4em;
     background-color: bisque;
     border-radius: 4em 4em 0 0;
    }

    在 dom 中再增加一些文本,包括標題、作者和面值:

    <div class="stamp">
     <div class="puppy">
     <!-- 略 -->
     </div>
     <p class="text">
     <span class="title">Puppy</span>
     <span class="author">comehope</span>
     <span class="face-value">80</span>
     </p>
    </div>

    設置標題的文字樣式:

    .text {
     position: relative;
     width: calc(100% + 2em * 2);
     height: 6em;
     font-family: sans-serif;
    }
    
    .text .title {
     position: absolute;
     font-size: 6em;
     font-weight: bold;
     color: sienna;
    }

    設置作者的文字樣式:

    .text .author {
     position: absolute;
     font-size: 3em;
     bottom: -1.2em;
     color: dimgray;
    }

    設置面值的文字樣式:

    .text .face-value {
     position: absolute;
     font-size: 14em;
     right: 0;
     line-height: 0.9em;
     color: darkcyan;
    }

    大功告成!

    聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

    文檔

    如何使用CSS的Grid布局實現小狗郵票(附源碼)

    如何使用CSS的Grid布局實現小狗郵票(附源碼):本篇文章給大家帶來的內容是關于如何使用CSS的Grid布局實現小狗郵票(附源碼),有一定的參考價值,有需要的朋友可以參考一下,希望對你有所幫助。效果預覽源代碼下載https://github.com/comehope/front-end-daily-challenges代碼解讀定義 d
    推薦度:
    標簽: 郵票 html5 源代碼
    • 熱門焦點

    最新推薦

    猜你喜歡

    熱門推薦

    專題
    Top
    主站蜘蛛池模板: 老汉精品免费AV在线播放| 精品国产黑色丝袜高跟鞋| 99久久精品国产一区二区| 亚洲精品无码久久千人斩| 99久久人人爽亚洲精品美女| 国产亚洲精品无码成人| 自拍偷自拍亚洲精品情侣| 精品国产呦系列在线观看免费| 国产精品亚洲精品观看不卡| 欧美精品hdvideosex4k| 亚洲福利精品一区二区三区| 99久久精品国产一区二区三区 | 久久久精品国产亚洲成人满18免费网站 | 久久综合国产乱子伦精品免费 | 亚洲国产精品ⅴa在线观看| 久草欧美精品在线观看| 国産精品久久久久久久| 久久久精品久久久久久| 久久亚洲精精品中文字幕| 亚洲一区二区三区在线观看精品中文| 国产精品视频分类一区| 久久久精品国产sm调教网站| 拍国产真实乱人偷精品| 无码国产乱人伦偷精品视频| 国产精品久久久久久福利69堂| 亚洲国产精品激情在线观看| 精品国产品香蕉在线观看75| 国产精品成人观看视频国产奇米| 无码人妻精品中文字幕| 在线精品自拍无码| 亚洲欧美精品一区久久中文字幕| 香蕉依依精品视频在线播放 | 无码人妻精品一区二区三区66 | 精品九九久久国内精品| 久久精品国产亚洲av麻豆小说| 无码精品黑人一区二区三区| 最新国产精品无码| 爽爽精品dvd蜜桃成熟时电影院| 国产在线国偷精品免费看| 久久国产精品免费| 亚洲国产精品综合久久一线|