Preface When writing front-end pages, we often use pictures such as small icons. If we use pictures, the code is more troublesome to write. Recently, I found a convenient and practical method that can be used directly. 1. Introducing picture operation methods First we enter the URL: https://www.iconfont.cn/ Method 1: font-class reference
Step 1: When we enter the website, we can see a search box. Directly enter the icon name you want, or you can search in the icon library. Step 2: Then add it to the shopping cart. Step 3: Click the shopping cart to create a new item and confirm. If you want to add pictures to the same item later, you don’t need to create it again. Step 4: The following page will appear. Copy the code and reference the code document. <link rel="stylesheet" href="http://at.alicdn.com/t/font_1587841_2580lrwj551.js"> Step 5: When importing the code, remember to add " http: " Step 6: Select the corresponding icon and get the class name, copy and paste it, use no-referrer" src="/img/bVbB5hz/view" src="https://cdn.segmentfault.com/v-5e05cb79/global/img/squares.svg" title="image.jpg"> <body> <i class\="iconfont icon-xxx"></i> </body> Method 2: symbol reference
Step 1: If a project needs to use multiple icons, you can also select the icons you want to use and add them to the shopping cart, then click Update Code, and then update the code reference link. This method needs to be downloaded locally. Step 2: After downloading, you can see some files in the folder and introduce the js file on the code page. <link rel="stylesheet" href="http://at.alicdn.com/t/font_1587841_2580lrwj551.js"> <script src="iconfont.js"></script> Step 3: Put the file package in the same directory as the project so that the icon reference can take effect. Step 4: In the same way, we copy and paste the image name in the svg file below the icon we need to reference, and replace href="change name". <svg class="icon" aria-hidden="true"> <use xlink:href="#icon-079aiqing"></use> </svg> Step 5: In the code page, in addition to importing the above two file addresses, we also need to import a style code. <style> .icon { width: 1em; height: 1em; vertical-align: -0.15em; fill: currentColor; overflow: hidden; } </style> Here is the full code for reference <!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>Alibaba vector image</title> <link rel="stylesheet" href="http://at.alicdn.com/t/font_1587841_2580lrwj551.js"> <script src="iconfont.js"></script> </head> <style> .icon { width: 1em; height: 1em; vertical-align: -0.15em; fill: currentColor; overflow: hidden; } </style> <body> <input type="text" placeholder="Search"> <svg class="icon" aria-hidden="true"> <use xlink:href="#icon-079aiqing"></use> </svg> </body> </html> Code effect: Summarize: The first method can be used directly by importing. It is quick and convenient, does not need to be downloaded, and is relatively easy to use. However, its disadvantage is that it can only be used in a single way and does not support colors. The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. |
<<: Pure CSS to solve the ceiling and bottom suction in H5 layout implementation steps
>>: Summary of all HTML interview questions
This article attempts to write a demo to simulate...
This article example shares the specific code of ...
1. concat() function Function: Concatenate multip...
There is no need to say much about the difference...
Code Knowledge Points 1. Combine fullpage.js to a...
The DIV floating effect (fixed position) is imple...
Table of contents MySQL multiple instances Multi-...
JSON (JavaScript Object Notation, JS Object Notat...
Background Recently, I encountered such a problem...
If you need to use an image to implement the use ...
The image tag is used to display an image in a we...
Lists for organizing data After learning so many ...
Server Status Analysis View Linux server CPU deta...
The benefits of using MySQL master-slave replicat...
Table of contents 1. How the Bootstrap grid syste...