如何使用HTML5 CSS3制作簡(jiǎn)單七巧板

今天來分享一個(gè)制作簡(jiǎn)單七巧板的方法(圖片如圖):

代碼如下:

首先在body中間寫四個(gè)div,在對(duì)其設(shè)置樣式如下:

這是對(duì)body中的div的樣式設(shè)置

#box1{

width: 0px;

height:0px;

border-top:140px solid rgb(199,233,125);

border-left:140px solid rgb(91,192,209);

border-right:140px solid red;

border-bottom:140px solid purple;

}

#box2{

width: 0px;

height:0px;

border-bottom:70px solid transparent;

border-right:70px solid yellow;

border-top:70px solid transparent;

border-left:70px solid transparent;

position: absolute;

top: 78px;

left:78px;

}

#box3{

width: 0px;

height:0px;

border-bottom:70px solid pink;

border-right:70px solid transparent;

border-top:70px solid transparent;

border-left:70px solid transparent;

position: absolute;

top: 148px;

left:8px;

}

#box4{

width: 0px;

height:0px;

border-bottom:70px solid rgb(250,204,70);

border-right:70px solid rgb(250,204,70);

border-top:70px solid transparent;

border-left:70px solid transparent;

position: absolute;

top: 148px;

left:148px;

}

思路:通過border屬性制作一個(gè)四色正方形,在分別用border畫出相應(yīng)的圖形,然后用定位(position)來調(diào)整元素的位置以來達(dá)到七巧板的效果,這方法是取巧做出的,也可以直接畫出,這個(gè)下次說。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容