简单写一下常见的基础图形,以及一些遇到的样式小图标 下图是css效果⬇
.
各个图形的代码如下:
Square(正方形)
- /*正方形*/
- .square {
- width: 60px;
- height: 60px;
- background: red;
- }
复制代码
Circle(圆形)
- /*圆形*/ /* 可以使用百分比值(大于30%),但是低版本的Android不支持 */
- .circle {
- width: 60px;
- height: 60px;
- background: red;
- -moz-border-radius: 30px;
- -webkit-border-radius: 30px;
- border-radius: 30px;
- }
复制代码
Triangle Up(正三角形)
- /*倒三角*/
- .triangle-down {
- width: 0;
- border: 30px solid red;
- border-left: 30px solid rgba(0, 0, 0, 0);
- border-right: 30px solid rgba(0, 0, 0, 0);
- /*border-top: 30px solid rgba(0, 0, 0, 0);*/
- border-bottom: 30px solid rgba(0, 0, 0, 0);
- }
复制代码
Triangle Down(倒三角形)
- /*倒三角*/
- .triangle-down {
- width: 0;
- border: 30px solid red;
- border-left: 30px solid rgba(0, 0, 0, 0);
- border-right: 30px solid rgba(0, 0, 0, 0);
- /*border-top: 30px solid rgba(0, 0, 0, 0);*/
- border-bottom: 30px solid rgba(0, 0, 0, 0);
- }
复制代码
Trapezoid(梯形)
- /*梯形*/
- .trapezoid {
- border-bottom: 60px solid red;
- border-left: 30px solid transparent;
- border-right: 30px solid transparent;
- height: 0;
- width: 60px;
- }
复制代码
Parallelogram(平行四边形)
- /*平行四边形*/
- .parallelogram {
- width: 100px;
- height: 60px;
- -webkit-transform: skew(20deg);
- -moz-transform: skew(20deg);
- -o-transform: skew(20deg);
- background: red;
- }
复制代码
Pentagon(五边形)
- /*五边形*/
- .pentagon {
- margin-top: 30px;
- position: relative;
- width: 54px;
- border-width: 50px 18px 0;
- border-style: solid;
- border-color: red transparent;
- }
- .pentagon:before {
- content: "";
- position: absolute;
- height: 0;
- width: 0;
- top: -85px;
- left: -18px;
- border-width: 0 45px 35px;
- border-style: solid;
- border-color: transparent transparent red;
- }
复制代码
Heart(心形)
- /*心形*/
- .heart {
- position: relative;
- width: 100px;
- height: 90px;
- }
- .heart:before,
- .heart:after {
- position: absolute;
- content: "";
- left: 50px;
- top: 0;
- width: 50px;
- height: 80px;
- background: red;
- -moz-border-radius: 50px 50px 0 0;
- border-radius: 50px 50px 0 0;
- -webkit-transform: rotate(-45deg);
- -moz-transform: rotate(-45deg);
- -ms-transform: rotate(-45deg);
- -o-transform: rotate(-45deg);
- transform: rotate(-45deg);
- -webkit-transform-origin: 0 100%;
- -moz-transform-origin: 0 100%;
- -ms-transform-origin: 0 100%;
- -o-transform-origin: 0 100%;
- transform-origin: 0 100%;
- }
- .heart:after {
- left: 0;
- -webkit-transform: rotate(45deg);
- -moz-transform: rotate(45deg);
- -ms-transform: rotate(45deg);
- -o-transform: rotate(45deg);
- transform: rotate(45deg);
- -webkit-transform-origin: 100% 100%;
- -moz-transform-origin: 100% 100%;
- -ms-transform-origin: 100% 100%;
- -o-transform-origin: 100% 100%;
- transform-origin: 100% 100%;
- }
复制代码
Diamond Square(菱形)
- /*菱形*/
- .diamond {
- width: 0;
- height: 0;
- border: 50px solid transparent;
- border-bottom-color: red;
- position: relative;
- top: -50px;
- }
- .diamond:after {
- content: '';
- position: absolute;
- left: -50px;
- top: 50px;
- width: 0;
- height: 0;
- border: 50px solid transparent;
- border-top-color: red;
- }
复制代码
Star (5-points)(五角星)
- /*五角星*/
- .star-five {
- margin: 50px 0;
- position: relative;
- display: block;
- color: red;
- width: 0;
- height: 0;
- border-right: 100px solid transparent;
- border-bottom: 70px solid red;
- border-left: 100px solid transparent;
- -moz-transform: rotate(35deg);
- -webkit-transform: rotate(35deg);
- -ms-transform: rotate(35deg);
- -o-transform: rotate(35deg);
- }
- .star-five:before {
- border-bottom: 80px solid red;
- border-left: 30px solid transparent;
- border-right: 30px solid transparent;
- position: absolute;
- height: 0;
- width: 0;
- top: -45px;
- left: -65px;
- display: block;
- content: '';
- -webkit-transform: rotate(-35deg);
- -moz-transform: rotate(-35deg);
- -ms-transform: rotate(-35deg);
- -o-transform: rotate(-35deg);
- }
- .star-five:after {
- position: absolute;
- display: block;
- color: red;
- top: 3px;
- left: -105px;
- width: 0;
- height: 0;
- border-right: 100px solid transparent;
- border-bottom: 70px solid red;
- border-left: 100px solid transparent;
- -webkit-transform: rotate(-70deg);
- -moz-transform: rotate(-70deg);
- -ms-transform: rotate(-70deg);
- -o-transform: rotate(-70deg);
- content: '';
- }
复制代码
Moon(月亮)
- /*月亮*/
- .moon {
- width: 80px;
- height: 80px;
- margin: 0 30px 20px 0;
- border-radius: 50%;
- box-shadow: 15px 15px 0 0 red;
- }
复制代码
Cut Diamond(钻石形)
[code] /*钻石形 |