Lancer le Studio
Vector Geometry & Responsive Layouts

SVG viewBox, Aspect Ratio & Responsive Scaling in CSS

Updated October 2026 • Responsive Design & Vector Geometry Series

Almost every vector sizing issue in CSS backgrounds and masks traces back to a misunderstanding of how the SVG viewBox attribute coordinates with CSS background-size and preserveAspectRatio.

1. What is viewBox?

The viewBox="min-x min-y width height" defines the virtual camera lens that crops and projects vector coordinates into the browser window. A valid viewBox is essential for responsive scaling; without it, vectors cannot scale proportionally and will clip.

2. Controlling Aspect Ratio

3. Responsive CSS Declarations

.icon-responsive {
  width: 24px;
  height: 24px;
  background-image: url('data:image/svg+xml,...');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

Convert and Normalize Vectors for Responsive CSS

Instant viewBox validation, SVGO minification, and CSS Data URI synthesis.

Open SVG to CSS Studio