O'Reilly logo

Sams Teach Yourself SVG in 24 Hours by Micah Laaker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using the viewBox

You saw earlier how an SVG document is similar to a bulletin board. Taking this analogy a step further, suppose you have five separate notes pinned in different locations on the bulletin board. However, rather than letting your audience see the entire bulletin board at one time, you decide they should see only one of the notes on the board. To achieve this sort of “peephole” view, the svg element uses an attribute called the viewBox.

As mentioned earlier, the top left corner of the SVG document is the (0,0) point. The viewBox honors the coordinates of a file's content but adjusts the display to match its coordinates. To do this, the viewBox has four values, each separated by a comma or a space. The first two values specify the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required