Home >
Web Front-end >
H5 Tutorial >
SVG (Scalable Vector Graphics) viewbox attributes viewbox and preserveAspectRatio
SVG (Scalable Vector Graphics) viewbox attributes viewbox and preserveAspectRatio
黄舟
Release: 2017-02-27 15:08:30
Original
2174 people have browsed it
In addition to the two basic width and height setting properties of width and height, SVG also has two more advanced properties viewbox and preserveAspectRatio
SVG Viewbox boxviewbox is an attribute on the svg tag
the graphics that were very small just now now become so big This is the wonder of viewbox
viewbox="0 0 30 30"0 0 specifies the coordinates of the origin (upper left) And 30 30 specifies the width of the svg High is equivalent to our customized coordinate system of svg Master Zhang Xinxu has a more vivid explanation of this:
SVG is like our monitor screen, and viewBox is a screenshot tool The selected box,
The final presentation is to display the screenshot content in the frame in full screen again on the monitor!
(If you specify only viewbox without specifying width and height, then the svg will occupy the entire screen) viewbox and viewportDue to the width of our svg above The height is 300×300, and we scaled it to 30×30
So it’s easy to figure it out But how would it behave if it were not scaled proportionally?
Below, the picture in "full screen mode" is called viewport (only width and height are specified)
And the picture in "screenshot mode" is called viewbox (width, height, viewbox is specified)
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