想要在網(wǎng)頁上畫出小黃人,我們需要使用CSS來進(jìn)行樣式設(shè)置。以下是實(shí)現(xiàn)小黃人的CSS樣式:
/*頭部*/ .head { width: 60px; height: 60px; border: 4px solid #000; border-radius: 50%; background-color: #ffe600; } .head:before { content: ""; display: block; width: 20px; height: 20px; border: 4px solid #000; border-radius: 50%; background-color: #fff; position: relative; top: -25px; left: 18px; } .head:after { content: ""; display: block; width: 10px; height: 10px; border: 4px solid #000; border-radius: 50%; background-color: #000; position: relative; top: -45px; left: 26px; } /*身體*/ .body { width: 80px; height: 100px; border: 4px solid #000; background-color: #ffe600; position: relative; top: -22px; left: -10px; border-radius: 10px; } /*手臂*/ .arm { width: 30px; height: 60px; border: 4px solid #000; border-top-left-radius: 50%; border-top-right-radius: 50%; position: relative; top: -70px; left: -25px; transform: rotate(30deg); } .arm.left { transform: rotate(-30deg); left: 70px; } /*腳*/ .foot { width: 20px; height: 60px; border: 4px solid #000; border-radius: 50% / 30%; position: relative; top: -120px; left: 13px; background-color: #000; } .foot.left { left: 47px; }
以上是CSS的代碼,接下來我們需要使用HTML將元素組合起來,從而完成小黃人的繪制。
<div class="head"></div> <div class="body"></div> <div class="arm"></div> <div class="arm left"></div> <div class="foot"></div> <div class="foot left"></div>
將以上代碼添加到HTML文件中,即可在網(wǎng)頁上繪制出你想要的小黃人了。