From the course: Creating Web Icons with SVG
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Add SVG as a background image
From the course: Creating Web Icons with SVG
Add SVG as a background image
- [Voiceover] In the previous movies, we've been talking about how to display individual SVGs as independent objects within a page. The key here is that the SVGs are part of the overall markup, an element on the page itself. Now is the time to look at how we can use SVGs as background elements in CSS because, as you know, when you have a box in a webpage, you can always inject a background image behind it using CSS. On the page right now, we're already doing that down here in the tags section. Each of these two tags you see is actually a PNG that's being generated through CSS. If I go to the exercise files for this movie, 03_06, and go to style.css and make a search for tag, you'll find the actual code that injects that tag right down here, .tag: :before, and all we're doing is displaying the background image in a box that is big enough to contain it on the page. This is a standard way of displaying icons instead of putting the icon into the markup and make it all confusing, we've…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Overview of the methods1m
-
(Locked)
Add SVG as a regular image4m 9s
-
(Locked)
Add backwards compatibility with SVGeezy4m 8s
-
(Locked)
Add SVG as an inline element4m 12s
-
(Locked)
Add backwards compatibility and more with SVGInjector6m
-
(Locked)
Add SVG as a background image2m 23s
-
(Locked)
Make SVG background images backward compatible1m 50s
-
(Locked)
A word on SVG accessibility4m 25s
-
(Locked)
-
-
-
-