CSS3 in practice
maddesigns | Sven Wolfermann
WebDevCon Hamburg, 17.10.2011
maddesigns | Sven Wolfermann
WebDevCon Hamburg, 17.10.2011
rounded corners! YEAH!!!!111eleven
border-radius: 20px;
border-radius: 10px 40px;
border-radius: 10px 40px 40px 10px;
border-radius: 10px / 40px;
border-radius: 50px;
border-radius: 50%;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
-o-border-radius: 4px;
-khtml-border-radius: 4px;
border-radius: 4px;
border-radius: 4px;
for sure
from version 4, a bit buggy in 3.6
from version 11.5
a bit buggy with border and percentage values
from version 9
”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.
The Conference for web developer
drop shadow - whoohoo!
-webkit-box-shadow: 2px 2px 5px black;
-moz-box-shadow: 2px 2px 5px black; /* FF 3.6 */
box-shadow: 2px 2px 5px black;
-webkit-box-shadow: 2px 2px 5px black;
box-shadow: 2px 2px 5px black;
-webkit-box-shadow: inset 2px 2px…
box-shadow: inset 2px 2px 5px black;
box-shadow: 0px 0px 10px black;
box-shadow: 0px 0px 10px 10px black;
box-shadow: 0px 15px 10px -10px black;
box-shadow: inset 0px 15px 10px -10px…
box-shadow: 0px 10px 5px red,
10px 0px 5px blue,
0px -10px 5px green,
-10px 0px 5px purple;
box-shadow: 0 0 0 5px red,
0 0 0 10px blue,
0 0 0 15px green,
0 0 0 20px purple;
box-shadow has not been distributed equaly to the different browsers, the manufacturers adopted box-shadow to their rendering engines separately
anyway
from version 4, since 3.5 with -moz-prefix
from version 10.5
from version 5.1, since 3.1 with -webkit-prefix
from version 9
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 */
The conference for web developer
We can drop vendor prefixes for box-shadow, background-clip, border-radius in CSS now.
by the way: shadow – what about text-shadow?
inset
is not supported
This text has shadow
text-shadow: 2px 2px 5px red;
I need glasses!
text-shadow: 2px 2px 8px gray;
color: transparent;
no question
from version 3.5
from version 9.5
from version 3.1
comes in version 10
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);
with :before
und :after
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; }
generating content with :before
positioning
add border
that
is supported
in all
browsers
even in IE8!
the conference for web developer
background: 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%); }
-webkit-linear-gradient(top, #c9de96 0%,#398235 100%);
-webkit-linear-gradient(left, #a6c742 0%,#68af21 100%);
-webkit-linear-gradient(bottom, #a6c742 0%,#68af21 100%);
-webkit-linear-gradient(right, #a6c742 0%,#68af21 100%);
to 33% light green » from 66% » green
-webkit-linear-gradient(top, #a6c742 0%, #a6c742 33%, #68af21 66%, #68af21 100%);
sharp edge at 50%
-webkit-linear-gradient(top, #a6c742 0%, #a6c742 50%, #68af21 50%, #68af21 100%);
from 0 to 50% to 100%
-webkit-linear-gradient(top, #a6c742 0%, #68af21 50%, #a6c742 100% );
light green » green » cyan
-webkit-linear-gradient(top, #a6c742 0%, #68af21 50%, #00aaaa 100% );
use linear-gradient for faux columns
-webkit-linear-gradient(left, #68af21 0%, #68af21 20%, #a6c742 20%, #a6c742 80%, #68af21 80%, #68af21 100%);
-webkit-linear-gradient(left, #a6c742 0%, #a6c742 50%, #68af21 50%, #68af21 100%);
background-size: 100px 100px;
-webkit-linear-gradient(-45deg, #a6c742 25%, #68af21 25%, #68af21 50%, #a6c742 50%, #a6c742 75%, #68af21 75%, #68af21 100%); background-size: 100px 100px;
other gradient functions
repeating-linear-gradient(red, blue 20px, red 40px); repeating-radial-gradient(red, blue 20px, red 40px);
with -webkit-prefix
with -moz-prefix
with -o-prefix
with -webkit-prefix
comes in IE10 with -ms-prefix
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:
The conference for web developer
in your @font-face (© Jake Archibald)
That's perfect!
@font-face { font-family: 'DINBold'; src: url("din-bold-webfont.eot"); src: url("din-bold-webfont.eot?#iefix") format("embedded-opentype"), url("din-bold-webfont.woff") format("woff"), url("din-bold-webfont.ttf") format("truetype"), url("din-bold-webfont.svg#DINBold") format("svg"); }
font: 48px/1.4 'Gloria Hallelujah', cursive;
http://www.google.com/webfonts
http://www.fontsquirrel.com/ @font-face generator
web DevCon
The conference for web developer