tcw | Blog

Web Design & UX




background sfumato (o gradiente) con CSS3

Category : CSS3, Grafica, Sviluppo Web · by Sep 26th, 2011

Gradiente Lineare (dall’alto verso il basso)


#miodiv {
/* fallback */

background-color: #1a82f7;

/* Safari 4-5, Chrome 1-9 */

background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#1a82f7), to(#2F2727));

/* Safari 5.1, Chrome 10+ */
background: -webkit-linear-gradient(top, #2F2727, #1a82f7);

/* Firefox 3.6+ */
background: -moz-linear-gradient(top, #2F2727, #1a82f7);

/* IE 10 */
background: -ms-linear-gradient(top, #2F2727, #1a82f7);

/* Opera 11.10+ */
background: -o-linear-gradient(top, #2F2727, #1a82f7);

}

Gradiente Lineare (da sinistra verso destra)


#miodiv {
/* fallback */

background-color: #1a82f7;

/* Safari 4-5, Chrome 1-9 */

background: -webkit-gradient(linear, left top, right top, from(#1a82f7), to(#2F2727));

/* Safari 5.1, Chrome 10+ */
background: -webkit-linear-gradient(left, #2F2727, #1a82f7);

/* Firefox 3.6+ */
background: -moz-linear-gradient(left, #2F2727, #1a82f7);

/* IE 10 */
background: -ms-linear-gradient(left, #2F2727, #1a82f7);

/* Opera 11.10+ */
background: -o-linear-gradient(left, #2F2727, #1a82f7);

}

Gradiente Radiale (centrato a dimensione piena)


#miodiv {
/* fallback */
background-color: #1a82f7;

/* Safari 4-5, Chrome 1-9 */
background: -webkit-gradient(radial, center center, 0, center center, 460, from(#1a82f7), to(#2F2727));

/* Safari 5.1, Chrome 10+ */
background: -webkit-radial-gradient(circle, #1a82f7, #2F2727);

/* Firefox 3.6+ */
background: -moz-radial-gradient(circle, #1a82f7, #2F2727);

/* IE 10 */
background: -ms-radial-gradient(circle, #1a82f7, #2F2727);

/* Opera non supporta gradienti radiali…*/

}

SHARE :