閑來無事,寫寫圖形。當時鞏固一下css3吧.。前端小白,寫的不好還請前輩多指教。
?
三角形
{ width: 0;height: 0;border-bottom: 140px solid red ;border-right: 70px solid transparent;border-left: 70px solid transparent;
}
圓形
{width: 0px;height: 0px;border:50px solid red;border-radius: 50%;
}
梯形
{width: 120px;height: 0px;border-bottom:120px solid red ;border-right: 60px solid transparent;border-left: 60px solid transparent;
}
平行四邊形
{width: 0px;height: 0px;border:100px solid red ;transform: skew(30deg);
}
菱形(實現方法有很多,這里只是兩個三角形合并,也就是正三角和倒三角)
.a{width: 0;height: 0;border-bottom: 140px solid red ;border-right: 70px solid transparent;border-left: 70px solid transparent;
}
.b{width: 0;height: 0;border-top : 140px solid red;border-left : 70px solid transparent; border-right : 70px solid transparent; }
橢圓形
{
width: 200px;height: 50px;border:1px solid red;border-radius:100px;
}
五邊形(這里使用一個三角形加一個正方形實現)
.a{width: 0;height: 0;border-bottom : 140px solid red;border-left : 70px solid transparent; border-right : 70px solid transparent; }.b{width: 140px;height: 140px;display: inline-block;border:1px solid red;background-color: red ;}
貪吃蛇蛇頭你敢信?哈哈
?
{width: 0px;height: 0px;border-radius: 50%;border:140px solid red;border-right :140px solid transparent;
}
?
扇形
?
{width: 0px;height: 0px;border-radius: 50%;border :140px solid transparent; border-bottom:140px solid red;
}
?登錄icon(兩個div,其中一個div設置一個margin-top的負值,移上來就好了)
?
.a{width: 0px;height: 0px;border-radius: 50%;border: 30px solid #000;}.b{width: 0px;border: 50px solid #000;border-top-right-radius: 50px;border-top-left-radius: 50px;border-top-width: 25px;border-bottom-width: 25px;}
再來一個小視頻 (用4個div拼接起來,兩個圓圈,一個長方形,一個梯形就好了)
.a{ display: inline-block;width: 20px;height: 20px;border-radius: 50%;border: 1px solid #000;}.b{ display: inline-block;width: 30px;height: 30px;border-radius: 50%;border: 1px solid #000;}.c{width: 80px;height: 50px;border: 1px solid #000;border-radius: 10px;}.d{height: 40px;border-right: 30px solid #000;border-top: 16px solid transparent;border-bottom: 16px solid transparent;border-radius: 10px;}<div><div class="a" style="margin-left:160px ;margin-top: 100px;"></div><div class="b" ></div>
</div>
<div><div class="c" style="margin-left:150px ; display: inline-block;vertical-align: top;"></div><div class="d" style="margin-left:0px ; display: inline-block;margin-top: -10px;"></div>
</div>
再來一個垃圾桶?三個圖形疊加。正方形,橢圓,和梯形。然后在設置一個傾斜就好了
.a{ width: 0px;height: 0px;border-radius: 4px;border: 8px solid #000;border-top-width: 0;margin-left:164px ;margin-top: 100px;}.b{ width: 0px;height: 0px;border-radius:8px ;border-top: 15px solid #000;border-left: 132px solid #000;margin-left: 108px;}.c{width: 78px;border-bottom-width: 100px;border-top: 100px solid #000;border-left: 18px solid transparent;border-right: 18px solid transparent;}<div style="display: inline-block;transform: rotate(9deg);"><div class="a"></div><div class="b"></div></div><div style="margin-left: 110px; margin-top: 18px;"><div class="c"></div></div>
本文轉載于:猿2048?https://www.mk2048.com/blog/blog.php?id=000bi2j&title=css3畫圖那些事(三角形、圓形、梯形等)