For years when designing web sites we'e had to use a lot of of image files--a lot!--for anything and everything. And I’m moving beyond content images here, thinking more about background images for textures, gradients, interesting borders, rounded corners, transparency, drop shadows, interesting fonts, and more.
This contributed to the whole experience being complicated, inflexible, and inefficient, with loads of assets and HTTP requests to deal with. Fast forward to the modern day, and the good news is that CSS now provides us with a lot of new tools for programmatically creating images for many common uses, making things a whole lot easier to handle.
In this talk Chris Mills will touch upon a number of more widely supported featured such as gradients, border-radius, border-image, and box-shadow, before moving on to what we can expect a bit further down the line with more nascent features like shaders, filters and masks. In addition, he will also briefly discuss what can be done about older browsers that do not support such features.
Advantages of Hiring UIUX Design Service Providers for Your Business
Getting rid of images with CSS
1. Getting rid of
images with CSS
CSS Summit 2013 // Chris Mills, Mozilla
Tuesday, 23 July 13
2. WhoamI? Senior tech writer @
Formerly tech writer & evangelist @
HTML, CSS, JS and Mobile enthusiast
Accessibility whingebag
Education agitator
Heavy metal geek dad
Tuesday, 23 July 13
5. Imgbad? Images are our friends!
But they are bloaty/HTTP heavy
(especially with RWD & hi-res devices)
Inflexible
And result in spaghetti markup/CSS
Tuesday, 23 July 13
20. CSS3etc. Maybe this talk shoulda been called
“Getting rid of images with CSS, SVG
and some other cool shit”
New features that make our lives easier
Tuesday, 23 July 13
22. opacity Programmatic transparent colours, via
RGBa, HSLa, opacity
But not in IE < 9
Specify a solid fallback colour
Or try a polyfill, like CSS3PIE
Tuesday, 23 July 13
24. webfonts Include whatever fonts you want
Great cross browser support, even
back to IE5.5
Use the bulletproof @font-face syntax
Use a hosted service, or generate it via
fontsquirrel.com
Tuesday, 23 July 13
29. webfonts File size can still be problematic
Create font subset using fontforge
Or use unicode-range to limit the
characters downloaded
http://24ways.org/2011/creating-
custom-font-stacks-with-unicode-
range/
Tuesday, 23 July 13
32. Corners The basics are very simple
Although you can actually do quite a
lot with it
http://lea.verou.me/humble-border-
radius/
Works in IE9+; polyfill with CSS3PIE
Tuesday, 23 July 13
45. multiple Multiple backgrounds go a long way
towards eradicating markup cruft
Separate background values via commas
Works in IE9+, provide fallback
declaration for older browsers
Mix gradients and images happily
Tuesday, 23 July 13
46. Multiplebody {
background:
url(../images/castle.png) top left no-repeat;
background:
url(../images/castle.png) top left no-repeat,
url(../images/clouds.png) top right no-repeat,
linear-gradient(top right, #3B6498, #C1CDDB);
}
Tuesday, 23 July 13
47. border
Border images are really interesting
IE10 + other browsers support it
Tuesday, 23 July 13
54. boxshdw box-shadows also have options
available for inset shadows, and wider
spread
Useful for many things, particularly
buttons that press in on :hover/:active!
Tuesday, 23 July 13
58. SVG SVG comparatively unknown amongst
web designers
(IE historically refusing to support it
is a large part of it)
But it is awesome, in so many ways
Tuesday, 23 July 13
59. SVG Create vector images using markup
Scales well, therefore great for RWD
issues
Embed directly into HTML, so cut
down on HTTP requests
Can manipulate using CSS and
JavaScript
Tuesday, 23 July 13
60. SVG IE<9 doesn’t support it, but this can
be polyfilled, e.g. with Raphaël or SVG
Web
Modern browsers have pretty good
support.
You can do some really interesting
stuff, like filters and masks
Tuesday, 23 July 13
61. SVG You needn’t be an expert to use it!
Export to SVG using Illustrator or
Inkscape
Then grab the code and put it in your
HTML
You can also embed it using <object>,
<img>, background-image ...
Tuesday, 23 July 13
62. SVG
...but you can’t directly mess with the
individual elements using CSS this way!
Tuesday, 23 July 13
66. Canvas <canvas> gets an honourable mention
Yes, umm, it’s an image
But it’s generated by JavaScript
You can draw + animate stuff, just like
with SVG/CSS
And you can polyfill, e.g. with ExCanvas
Tuesday, 23 July 13
69. Canvas But <canvas> isn’t the best for this
kind of stuff
Easier to use SVG/CSS
And <canvas> text is inaccessible
Tuesday, 23 July 13
70. Canvas <canvas> is much better for data
analysis and visualisation
And other things that require logic,
such as games
Also good for on-the-fly image
processing via drawImage() and
toDataURL()
Tuesday, 23 July 13
75. CSS3etc. Neat stuff on the way from the CSS
WG / FXTF
Some SVG stuff being brought over to
CSS
New ways to deal with images as well
as create visuals
Tuesday, 23 July 13
81. blending Blend modes also on the way
Like you’ve abused in Photoshop
http://maxvujovic.blogspot.co.uk/
2013/04/all-blend-modes-for-css-
custom-filters.html
Tuesday, 23 July 13
84. masks CSS masks were a proprietary WebKit
feature for quite a while
Now on their way in the W3C
http://thenittygritty.co/css-masking
Tuesday, 23 July 13
88. dead!!! I’ve already looked at polyfills and
fallbacks for old browsers
In general you need to do what is best,
project by project
Is client happy with a different look in
older browsers?
Tuesday, 23 July 13
89. modernizr Modernizr is often a good option
Feature detect support for your
experimental features
Then provide different CSS/JS where
support is lacking
For a more tailored experience
Tuesday, 23 July 13
91. Credits Background grunge image:
themescompany.com
Fonts: Carbon type, Bebas Neue, Dakota,
Andale mono
Thanks to all the amazing people whose
work I’ve referenced
Tuesday, 23 July 13