- @estellevw
- @standardista
- http://www.standardista.com
- This deck: http://estelle.github.com/gradients/30.html
- Deeper Dive: http://estelle.github.com/gradients/
Really old Webkit Syntax (i.e. Older Android, iPhone devices)
-webkit-gradient(linear, startX startY, endX endY,
color-stop,
color-stop);
Color Stop
color-stop(0-1, color)
Example
background-image:
-webkit-gradient(linear, 0 0, 100% 100%,
color-stop(0.5, rgba(255, 255, 255, 0.25)),
color-stop(0.5, rgba(255, 255, 255, 0.5)),
color-stop(1, rgba(255, 255, 255, 0)));
background-color: indianred;
-prefix-gradient(<angle>|<term>, <colorstop>, <colorstop>)
Color Stop
color length
Example
background-image:
-prefix-linear-gradient(270deg,
indianred 0%,
palegoldenrod 100%);
linear-gradient(<angle>| to <term>, <colorstop>, <colorstop>)
Key differences:
/* Archaic Syntax */ background-image: -webkit-gradient(linear, 0 0, 0 100%, color-stop(0.1, indianred), color-stop(0.9, palegoldenrod); /* Supported prefixed syntax */ background-image: -prefix-linear-gradient(top, indianred 10%, palegoldenrod 90%); /* Standards Syntax FF16 / O 12.1 / Chrome 25 / IE 10 */ background-image: linear-gradient(to bottom, indianred 10%, palegoldenrod 90%);
background: linear-gradient(
indianred, palegoldenrod);
<angle> to top to bottom to left to right to top left to top right to bottom left to bottom right
background-image:
-prefix-linear-gradient(
indianred,
palegoldenrod);
background-image:
-prefix-linear-gradient(top,
indianred,
palegoldenrod);
background-image:
-prefix-linear-gradient(270deg,
indianred 0%,
palegoldenrod 100%);
Prefixed -webkit-, -moz-, -ms-, -o-
* legacy syntax, ** future syntax
We're not covering radial gradients. They're REALLY bad for performance reasons. But, the slides are here if you want to learn about them later.
Continue: Mobile CSS3: Main Deck
Continue: Mobile CSS3: Animation
.thisSlide {
background-image:
radial-gradient(
palegoldenrod,
#BDD9D5);
}
.thisSlide {
background-image:
radial-gradient(25% 35%,
palegoldenrod,
#BDD9D5);
}
.thisSlide {
background-image:
radial-gradient(25% 35%,
palegoldenrod 20%,
#BDD9D5 20%);
}
.thisSlide {
background-image:
radial-gradient(75% 75%, circle,
palegoldenrod 20%,
#BDD9D5 20%);
}
.thisSlide {
background-image:
radial-gradient(75% 75%,
farthest-corner,
palegoldenrod,
#BDD9D5);
}
.thisSlide {
background-image:
radial-gradient(
circle,
#BDD9D5 50%,
palegoldenrod 50%);
background-size: 100px 100px;
background-repeat: repeat;
background-color: red;
}
Up Next?