当前位置:网站首页>Graphic analysis of viewbox in SVG
Graphic analysis of viewbox in SVG
2022-06-12 08:36:00 【Month to month better】

svg There is one of them. viewbox attribute , Visual area , Is in the svg Take a small piece from , Zoom in to the whole svg Show .
This attribute is a little difficult to understand for beginners , Here's a simple example , It's easy to see .
1) Let's have one first svg, Width and height, everyone 300, Set the border :
<svg width="300" height="300" style="border: 1px solid steelblue">
</svg>
Running effect :

This is actually a 300*300 The rectangular .
2)svg Draw a rectangle inside :
<svg width="300" height="300" style="border: 1px solid steelblue">
<rect x="10" y="10" width="200" height="100" fill="skyblue"></rect>
</svg>
Running effect :
3) Set up svg Of viewbox attribute :
<svg width="300" height="300" style="border: 1px solid steelblue"
viewbox="105 55 60 60">
<rect x="10" y="10" width="200" height="100" fill="skyblue"></rect>
</svg>
First analyze the principle , Let's see the effect , Above set viewbox The value of is :105 55 60 60, The meaning of each parameter is as follows :
105 Means relative to svg The abscissa of the upper left corner .
55 Means relative to svg The ordinate of the upper left corner .
60 Represents the width of the intercepted viewport .
60 Indicates the height of the intercepted viewport .
Schematic principle :

4) Non proportional viewbox
above viewbox Width and height svg In equal proportion , If equal proportions , Then one side is placed on the largest .
<svg width="300" height="300" style="border: 1px solid steelblue"
viewbox="105 55 60 60">
<rect x="10" y="10" width="200" height="100" fill="skyblue"></rect>
</svg>
Schematic principle :
边栏推荐
- ctfshow web4
- Installation series of ROS system (I): installation steps
- Engineers learn music theory (III) interval mode and chord
- Hands on learning and deep learning -- simple implementation of linear regression
- Gtest/gmock introduction and Practice
- Knee joint
- Project sorting of niuke.com
- Hands on deep learning -- image classification dataset fashion MNIST
- 进制GB和GiB的区别
- js中的正则表达式
猜你喜欢

What should be paid attention to when establishing MES system? What benefits can it bring to the enterprise?

Beidou satellite navigation system foundation part 1

根据有效期显示距离当前还剩多少天有效期

Hands on learning and deep learning -- simple implementation of linear regression

ctfshow web 1-2

Installation series of ROS system (II): ROS rosdep init/update error reporting solution

What is the MES system? What is the operation process of MES system?

ctfshow web3

调整svg宽高

Hands on learning and deep learning -- Realization of linear regression from scratch
随机推荐
MES helps enterprises to transform intelligently and improve the transparency of enterprise production
Database foundation -- normalization and relational schema
ctfshow web4
A brief summary of C language printf output integer formatter
js中的正则表达式
牛客网的项目梳理
Hypergeometric cumulative distribution test overlap
记Date类型的一次踩坑
Regular expressions in JS
(p33-p35) lambda expression syntax, precautions for lambda expression, essence of lambda expression
Engineers learn music theory (II) scale and tendency
Hands on learning and deep learning -- a brief introduction to softmax regression
vscode 下载慢解决办法
Loading font component loading effect
js中的数组
Ankerui fire emergency lighting and evacuation indication system
(p27-p32) callable object, callable object wrapper, callable object binder
Engineers learn music theory (I) try to understand music
Hands on deep learning -- weight decay and code implementation
FDA审查人员称Moderna COVID疫苗对5岁以下儿童安全有效