HTML Svg ViewBox Attribute - Dofactory
Có thể bạn quan tâm
- SQL
SQL Tutorial SQL Reference Connection Strings
- .NET
C# Design Patterns C# Coding Standards C# Code Examples Visual Studio Shortcut Keys
- HTML
HTML Tutorial HTML Reference
- CSS
CSS Tutorial CSS Reference
- JavaScript
JavaScript Tutorial JavaScript Design Patterns
- SQL
- .NET
- HTML
- CSS
- JavaScript
Select tutorial
![](/img/dotgray.jpg)
![](/img/dotgray.jpg)
![](/img/dotgray.jpg)
Select tutorial
![](/img/dotgray.jpg)
![](/img/dotgray.jpg)
![](/img/dotgray.jpg)
![](/img/dotgray.jpg)
Select tutorial
![](/img/dotgray.jpg)
![](/img/dotgray.jpg)
Select tutorial
![](/img/dotgray.jpg)
![](/img/dotgray.jpg)
Select tutorial
![](/img/dotgray.jpg)
![](/img/dotgray.jpg)
![](/img/arrow-left.jpg)
- HTML Tutorial
- HTML Reference
- CSS Tutorial
- CSS Reference
- SQL Tutorial
- SQL Reference
- JavaScript Tutorial
- JavaScript Patterns
- C# Design Patterns
- C# Coding Standards
- Connection Strings
- Visual Studio Shortcuts
The viewBox attribute on an <svg> tag specifies the position and size of the svg image.
This is used to scale SVG element.
Example
#
A viewBox attribute on an <svg>. The coordinate system is in 0-100 units whereas the real dimensions are 200 x 200 pixels.
<svg viewBox="0 0 100 100" width="200" height="200"> <g transform="translate(50,50)"> <path d="M38,-1h12v2h-12zM-38-1h-12v2h12z"/> <path d="M40,-1h8v2h-8zM-40-1h-8v2h8z" transform="rotate(30)"/> <path d="M40,-1h8v2h-8zM-40-1h-8v2h8z" transform="rotate(60)"/> <path d="M38,-1h12v2h-12zM-38-1h-12v2h12z" transform="rotate(90)"/> <path d="M40,-1h8v2h-8zM-40-1h-8v2h8z" transform="rotate(120)"/> <path d="M40,-1h8v2h-8zM-40-1h-8v2h8z" transform="rotate(150)"/> <path d="M-0.5,0v-35h1v35z"/> <path d="M0,-0.75h30v1.5h-30z"/> <path d="M0,-0.75h30v1.5h-30z" transform="rotate(-30)" fill="#888"/> <circle r="2"/> </g> </svg> Try it liveUsing viewBox
#
The viewBox is an attribute of the SVG element in HTML.
This attribute is used to scale the SVG element.
The SVG coordinates with origin, width, and height are defined with this attribute.
Syntax
#
<svg viewBox = "min-x min-y width height">Values
#
Value | Description |
---|---|
min-x | Defines the origin on the horizontal axis (i.e left to right). |
max-x | Defines the origin on the vertical axis (i.e top to bottom). |
width | Defines the width of the viewbox. |
height | Defines the height of the viewbox. |
Browser support
#
Here is when viewBox support started for each browser:
![]() | 4.0 | Jan 2010 |
![]() | 3.0 | Jun 2008 |
![]() | 9.0 | Mar 2011 |
![]() | 10.1 | Jun 2010 |
![]() | 3.2 | Nov 2008 |
You may also like
#
- Our HTML svg Tag Referencee
- Our HTML canvas Tag Reference
- Our CSS Images Tutorial
![Jack Poorte](/img/jack-poorte-cropped.jpg)
- HTML Tables
- HTML Images
- HTML Color Names
- HTML Links
- HTML Tags
- HTML Lists
- HTML Forms
- HTML Buttons
- HTML Spaces
- HTML Checkboxes
- HTML Editors
- HTML Comments
- viewBox Attribute
- Example
- Using viewBox
- Syntax
- Values
- More Examples
- Browser support
- You may also like
Từ khóa » Html Scale Svg Element
-
How To Scale SVG | CSS-Tricks
-
Resizing SVG In Html? - Stack Overflow
-
Scale - SVG: Scalable Vector Graphics - MDN Web Docs
-
Basic Transformations - SVG: Scalable Vector Graphics | MDN
-
Intrinsic Sizing - SVG
-
How To Make An Svg Scale With Its Parent Container ? - GeeksforGeeks
-
How To Resize SVG In HTML - W3docs
-
Html Scale Svg Code Example - Code Grepper
-
Scale SVG Graphics With Only Css - Gists · GitHub
-
Resizing An SVG When The Window Is Resized In D3.js - Chartio
-
SVG Viewport And ViewBox (For Complete Beginners) - Web Design
-
Scaling SVG Elements - CodePen
-
Html – Scale An SVG Element Using A Transform Origin - ITecNote
-
How To Resize A SVG Image - Medium