How to make icon from symbol in svg
The content of this article is about how to create icons from symbols in svg. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
1. cnpm i gulp -g
2. Create a new gulpfile.js file
var gulp = require('gulp'); var svgSymbols = require('gulp-svg-symbols'); gulp.task('sprites',function(){ return gulp.src('assets/svg/*.svg').pipe(svgSymbols()).pipe(gulp.dest('assets')); })
3. Create a new assets/svg and put the downloaded svg into the svg file
Tip: Change the svg file name to the required id
4. Run gulp sprites
5. Use it directly in HTML
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <style> .icon{ width:32px; height:32px; fill:red; } </style> </head> <body> <svg class="icon"> <use xlink:href="/assets/svg-symbols.svg#boat"></use> </svg> </body> </html>
Related articles Recommended:
SVG drawing function: svg to draw a flower (with code)
The use of
The above is the detailed content of How to make icon from symbol in svg. For more information, please follow other related articles on the PHP Chinese website!

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

AI Hentai Generator
Generate AI Hentai for free.

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

How to use SVG to achieve image mosaic effect without using Javascript? The following article will give you a detailed understanding, I hope it will be helpful to you!

svg can be converted to jpg format by using image processing software, using online conversion tools, and using the Python image processing library. Detailed introduction: 1. Image processing software includes Adobe Illustrator, Inkscape and GIMP; 2. Online conversion tools include CloudConvert, Zamzar, Online Convert, etc.; 3. Python image processing library, etc.

svg images are widely used in projects. The following article will introduce how to use svg icons in vue3 + vite. I hope it will be helpful to everyone!

With the continuous development of modern Web front-end development, more and more technologies are widely used in actual development. Among them, Vue.js is currently one of the most popular JavaScript frameworks. It is based on the MVVM model and provides a rich API and component library, making it easier to develop responsive, reusable, and efficient web applications. The latest version of Vue.js3 has better performance and richer features than the old version, which has attracted widespread attention and research. This article will introduce to you a

Laravel Elixir is a popular front-end automation tool set based on Gulp, which simplifies many tasks that previously required manual work. But Laravel Elixir's elegant API design does not mean that developers do not need to understand the use of Gulp at all. On the contrary, understanding the use of Gulp can better understand the working principle of Laravel Elixir and improve development efficiency. This article will introduce how to use Gulp in Laravel Elixir framework

How to add logo to favicon using SVG? The following article will introduce to you how to use SVG to generate favicon with logo. I hope it will be helpful to you!

To draw HTMLImageElements on a canvas element, use the drawImage() method. This method defines an Image variable using src="mySVG.svg" and uses drawImage when loading. varmyImg=newImage();myImg.onload=function(){ ctx.drawImage(myImg,0,0);}img.src="http://www.example.com/files/sample.svg";

1. Install svg-sprite-loadernpminstallsvg-sprite-loader--save-dev 2. Create a new component under src/components/svgIcon index.vueimport{computed}from"@vue/reactivity";exportdefault{name:"baseSvgIcon", props:{iconClass:{type:String},className:{type:String},},setup
