Home >Web Front-end >CSS Tutorial >CSS methods for drawing various graphics

CSS methods for drawing various graphics

高洛峰
高洛峰Original
2017-02-15 13:25:451408browse

CSS methods of drawing various graphics

Square(square)

CSS绘制各种图形的方法

#square{
    width:100px;
    height:100px;
    backgroud:red;
}

Rectangle(rectangle)

CSS绘制各种图形的方法

#rectangle {
    width: 200px;
    height: 100px;
    background: red;

Circle

CSS绘制各种图形的方法

#circle {
    width: 100px;
    height: 100px;
    background: red;
    -moz-border-radius: 50px;
    -webkit-border-radius: 50px;
    border-radius: 50px;
}

/ Percentage values ​​(greater than 50%) can be used, but lower versions of Android cannot Support /


Oval(oval)

CSS绘制各种图形的方法

#oval {
    width: 200px;
    height: 100px;
    background: red;
    -moz-border-radius: 100px / 50px;
    -webkit-border-radius: 100px / 50px;
    border-radius: 100px / 50px;
}

/ Percentage value (greater than 50%) can be used, but lower versions of Android do not support it /


Triangle Up(Upward Triangle)

CSS绘制各种图形的方法

#triangle-up {
    width: 0;
    height: 0;
    border-left: 50px solid transparent;
    border-right: 50px solid transparent;
    border-bottom: 100px solid red;
}

Triangle Down(Down)

CSS绘制各种图形的方法

#triangle-down {
    width: 0;
    height: 0;
    border-left: 50px solid transparent;
    border-right: 50px solid transparent;
    border-top: 100px solid red;
}

Triangle Left

CSS绘制各种图形的方法

 #triangle-left {
    width: 0;
    height: 0;
    border-top: 50px solid transparent;
    border-right: 100px solid red;
    border-bottom: 50px solid transparent;
}

Triangle Right

CSS绘制各种图形的方法

#triangle-right {
    width: 0;
    height: 0;
    border-top: 50px solid transparent;
    border-left: 100px solid red;
    border-bottom: 50px solid transparent;
}


CSS method of drawing various graphics


Square (square)

CSS绘制各种图形的方法

#square{
    width:100px;
    height:100px;
    backgroud:red;
}

Rectangle(rectangle)

CSS绘制各种图形的方法

#rectangle {
    width: 200px;
    height: 100px;
    background: red;

Circle(circle)

CSS绘制各种图形的方法

#circle {
    width: 100px;
    height: 100px;
    background: red;
    -moz-border-radius: 50px;
    -webkit-border-radius: 50px;
    border-radius: 50px;
}

/ Percentage values ​​(greater than 50%) can be used, but lower versions of Android do not support it/


Oval (oval)

CSS绘制各种图形的方法

#oval {
    width: 200px;
    height: 100px;
    background: red;
    -moz-border-radius: 100px / 50px;
    -webkit-border-radius: 100px / 50px;
    border-radius: 100px / 50px;
}

/ Percentage values ​​(greater than 50%) can be used, but lower versions of Android do not support it/


Triangle Up (upward triangle)

CSS绘制各种图形的方法

#triangle-up {
    width: 0;
    height: 0;
    border-left: 50px solid transparent;
    border-right: 50px solid transparent;
    border-bottom: 100px solid red;
}

Triangle Down

CSS绘制各种图形的方法

#triangle-down {
    width: 0;
    height: 0;
    border-left: 50px solid transparent;
    border-right: 50px solid transparent;
    border-top: 100px solid red;
}

Triangle Left

CSS绘制各种图形的方法

 #triangle-left {
    width: 0;
    height: 0;
    border-top: 50px solid transparent;
    border-right: 100px solid red;
    border-bottom: 50px solid transparent;
}

Triangle Right(right)

CSS绘制各种图形的方法

#triangle-right {
    width: 0;
    height: 0;
    border-top: 50px solid transparent;
    border-left: 100px solid red;
    border-bottom: 50px solid transparent;
}
For more CSS methods to draw various graphics and related articles, please pay attention to the PHP Chinese website!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:CSS Compatibility GuideNext article:CSS Compatibility Guide