How to make cool dynamic icons with SVG? (code example)
This chapter will introduce to you how to use SVG to create cool dynamic icons in HTML5? (code example). It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
1. Basic graphic elements
svg has some predefined shape elements: rectangle
<!-- viewBox定义画布大小 width/height定义实际大小 --> <svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="300" height="300" viewBox="0 0 300 300"> <!-- 直线 (x1,y1)与(x2,y2)为两点坐标 --> <line x1="0" y1="0" x2="250" y2="30" /> <!-- 多边形 通过多个点的坐标形成封闭图形 --> <polygon points="5,5 100,100 50,200" /> <!-- 矩形 (x,y)为左上角起始点 --> <rect x="100" y="100" width="120" height="100" /> <!-- 圆形 (cx,cy)圆心点 r半径 --> <circle cx="100" cy="50" r="40" stroke="black"/> <!-- 文本 (x,y)左下角坐标 --> <text x="0" y="20" style="font-size:16px;font-weight: bold">Try SVG</text> </svg>
2. Style and effect
The style of the svg element can be written as the attribute of the tag, or it can be written in style. Here are some main style attributes:
stroke: stroke color
stroke-width: stroke width
stroke-opacity: Transparency of stroke
fill: fill color, i.e. background
fill-opacity: transparency of fill color
Transform: graphics transformation, similar to css3 transform
svg also supports many filter effects, such as gradient, shadow, blur, image mixing, etc. You don’t need to know that much. For example, if you want to draw a few colored circles, just use circle and fill.
Note: transform defaults to the upper left corner of svg as the base point, not the center of the circle or other center. The upper left corner is the origin of the svg coordinate system. To understand transform and coordinate system, you can refer to here.
3. Auxiliary elements
svg has several auxiliary elements:

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.
