CSS3 in practice

maddesigns | Sven Wolfermann
WebDevCon Hamburg, 17.10.2011

use arrow keys to navigate

border-radius

rounded corners! YEAH!!!!111eleven

border-radius

border-radius » enlarge box

border-radius » browser-specific prefixes

-webkit-border-radius: 4px;
-moz-border-radius: 4px;
-o-border-radius: 4px;
-khtml-border-radius: 4px;
border-radius: 4px;
      	

border-radius » browser support

border-radius » browser support

”But my IE7 does not show rounded corners!“

It doesn't have to!

There is no good (simple) way to show rounded corners in IE6-8. The better approach is to omit rounded corners.

The content will not get better with rounded corners.

Browser market in Europe

rounded corners

web DevCon

The Conference for web developer

box-shadow

drop shadow - whoohoo!

box-shadow » browser specific prefixes?

-webkit-box-shadow: 2px 2px 5px black;
-moz-box-shadow: 2px 2px 5px black;  /* FF 3.6 */
box-shadow: 2px 2px 5px black;
      	

box-shadow » different offset / spread values

multiple box-shadows

box-shadow » cross browser rendering

box-shadow has not been distributed equaly to the different browsers, the manufacturers adopted box-shadow to their rendering engines separately

Overview of different implementations

box-shadow » browser support

What the heck am I goin to do with IE6-IE8?

well...

There are ways, Dude. You don't wanna know about it, believe me.

filter:progid:DXImageTransform.Microsoft.Shadow⏎
(color=#e2e2e2, Direction=135, Strength=5); /* IE6-7 */
-ms-filter:"progid:DXImageTransform.Microsoft.Shadow⏎
(color=#e2e2e2, Direction=135, Strength=5)"; /* IE8 */
zoom: 1; /* trigger hasLayout */
      	

rounded corners

drop shadow

web DevCon

The conference for web developer

We can drop vendor prefixes for box-shadow, background-clip, border-radius in CSS now.
Divya Manian (Opera)

text-shadow

by the way: shadow – what about text-shadow?

text-shadow » value set like box-shadow

inset is not supported

Meet the Letter-Heads – Mozilla text-shadow demo

text-shadow » browser support

ok... but for current Internet Explorer versions?

if text-shadow is assigned, the text will be displayed without shadow in IE.

you can try a filter but that interferes with the font rendering of IE - it looks ugly and is therefore not recommended!

/* IE6-7 */
filter:progid:DXImageTransform.Microsoft.DropShadow⏎
(color:#333333, offx=3, offy=3);
zoom: 1; /* trigger hasLayout */
 /* IE8 */
-ms-filter:"progid:DXImageTransform.Microsoft.DropShadow⏎
(color:#333333, offx=3, offy=3);
      	

generating content

with :before und :after

A use case for :before und :after

A use case for :before und :after

the headline

h3 {
  background-color: #68af21;
  color: white;
  font-size: 36px;
  padding: 20px;
  position: relative;
  border-radius: 12px;
}
/* step 1 */
h3:before { 
  content: "\0020"; 
  display: block;
  position: absolute;
  width: 0; 
  height: 0;
  z-index: 2;
/* step 2 */
  bottom: -40px; 
  left: 50px;
/* step 3 */
  border-top-color: #68af21; 
  border-style: solid;
  border-width: 20px;
}

      	
  1. generating content with :before

  2. positioning

  3. add border

The Shapes of CSS — http://l.maddesigns.de/p5Q08r

:before & :after » browser support

rounded corners

drop shadow

generating content

web DevCon

the conference for web developer

background gradients

background: linear-gradient();

linear-gradient

current overhead for all browsers

.gradient { 
	
  background-color: yellow; /* Fallback Color */
  background: -webkit-gradient(linear,left top,left bottom,from(yellow),to(blue));
  background: -webkit-linear-gradient(top, yellow 0%, blue 100%); 
  background:    -moz-linear-gradient(top, yellow 0%, blue 100%); 
  background:     -ms-linear-gradient(top, yellow 0%, blue 100%); 
  background:      -o-linear-gradient(top, yellow 0%, blue 100%); 
  
  /* current W3C standard, not implemented yet */
  background:         linear-gradient(to bottom, yellow 0%, blue 100%);
  
}

linear-gradient

linear-gradient — multistage (stop colors)

linear-gradient — multistage (stop colors)

linear-gradient — sharp edges

linear-gradient — sharp edges

linear-gradient — sharp edges

CSS3 Patterns Gallery by Lea Verou

Gradients in CSS3

other gradient functions

repeating-linear-gradient(red, blue 20px, red 40px);
repeating-radial-gradient(red, blue 20px, red 40px);

gradients » browser support

Hm, so can I really use it with real world projects?

Sure!

 

To be honest, it's a prefix hell but works pretty good. And for IE, a PNG background fallback is the best solution.

And here is a nice online helper for gradient CSS:

http://www.colorzilla.com/gradient-editor/

rounded corners

drop shadow

generate content

background gradient

web DevCon

The conference for web developer

Web-Fonts

in your @font-face (© Jake Archibald)

Web-Fonts are supported in every browser even in IE6

Font-Face assignment

font: 48px/1.4 'Gloria Hallelujah', cursive;
      	

normal font

font with webfonts

 

http://www.google.com/webfonts

http://www.fontsquirrel.com/ @font-face generator

rounded corners

drop shadow

generate content

linear gradients

webfonts

web DevCon

The conference for web developer

Thank you for your attention!

 

Who was that dude?

Sven Wolfermann - Certified TYPO3 Integrator