Backgrounds múltiples en CSS3 y un truco gradual

27/Jun/2012 3839

Con CSS3 el soporte a múltiple background nos permite ser mucho más creativos al momento de solucionar problemas de estilos, cuando antes sólo dependíamos de crear y anidar etiquetas y cortar esos gif’s y png’s que tanto nos han atormentado.

La sintaxis para fondos múltiples es bastante intuitiva:

background: url(…) top left no-repeat, url(…) right bottom no-repeat;

Su soporte -a la fecha según caniuse.com– es favorable para los browsers modernos. Para los que no lo soporten esta declaración será totalmente ignorada, por lo que mi recomendación es que primero definas un background como fallback y luego escribas los múltiples que necesites.

Ver ejemplo 1

Fondos con gradientes

Como algunos ya podrán haber probado, con CSS3 podemos crear gradientes (lineales o radiales) y tratarlos directamente como imágenes. Su soporte también ya está ampliado y la sintaxis es familiar:

background-image: -webkit-gradient(linear, 0 top, 0 bottom, from(#f00), to(#f60));

Aunque no se han puesto de acuerdo con normalizarla, así es para Firefox:

background-image: -moz-linear-gradient(90deg, #f00, #f60);

Ver ejemplo 2

El truco

Necesitaba unir en el fondo del <body> un patrón como imagen en png, con un fondo gradiente radial. Lo que se haría antes sería el fondo gigantesco ya con el gradiente y el patrón, el cual pesaría muchos kilos y lo pondría como fondo del <body> (quizás con el fondo al 100%), pero ahora la cosa cambió. Como el gradiente para CSS es una imagen, podemos utilizarlo como un background-image más. El código quedó de la siguiente manera:

background-color: #141414;
background-image: url('pattern.png');
background-image: url('pattern.png'), -webkit-gradient(linear, 50% 50%, 0, 50% 50%, 500, from(#f00), to(#300));
background-image: url('pattern.png'), -webkit-linear-gradient(#f00, #300);
background-image: url('pattern.png'),    -moz-linear-gradient(#f00, #300);
background-image: url('pattern.png'),    -ms-linear-gradient(r#f00, #300);
background-image: url('pattern.png'),      -o-linear-gradient(#f00, #300);
background-image: url('pattern.png'),         linear-gradient(#f00, #300);

Ver ejemplo 3

Links:

Comentarios

  1. gfvkxc [#]

    Ssbspb onarluwkidan, [url=http://qphyijtfnnkk.com/]qphyijtfnnkk[/url], [link=http://hznkzdoyprir.com/]hznkzdoyprir[/link], http://aodrgemhbnum.com/

  2. Miablabs [#]

    tadalafil generic cialis

  3. www.pharmaceptica.com [#]

    price of sildenafil tablets https://www.pharmaceptica.com/

  4. ivermectin tablets walmart [#]

    ivermectin pills amazon https://stromectolforte.com/# ivermectin tablets order ivermektin tabletter storbritannien

  5. ivermectin online order [#]

    stromectol an effective replacement for ivermectin https://stromectolforte.com/# ivermectin pills human ivermectin

  6. Wimblabs [#]

    glyburide metformin

  7. Ivyblabs [#]

    generic tadalafil usa

  8. isotretinoine [#]

    accutane for acne how does accutane work

  9. stromectolforte.com [#]

    how to obtain ivermectin http://stromectolforte.com/# ivermectin tablets ivermectin over the counter

  10. stromectolforte.com [#]

    ivermectin price usa https://stromectolforte.com/# custo da pГ­lula de ivermectina price of stromectol

  11. iwermectin.com [#]

    http://www.my 15 year old lab has arthritis in his back legs falls down alot what can i use http://iwermectin.com – generic stromectol

  12. stromectolforte.com [#]

    how much is ivermectin http://stromectolforte.com/# ivermectin generic ivermectin

  13. bactrim and alcohol [#]

    https://bactrimhoprim.com/ sulfamethoxazole tmp

  14. steroidsprednisone [#]

    prednisolon https://deltasoneprednisone.com/

  15. accutane medication [#]

    buy isotretinoine isotretinoine

  16. modafinilandalcohol [#]

    modafinil moa where to buy modafinil reddit

  17. ivermectin lotion [#]

    ivermectin dosage chart for humans parasites http://stromectolforte.com/ ivermectina dosis en humanos pЕ‚yn stromektolowy

  18. stromectolforte.com [#]

    canine ivermectin for sale http://stromectolforte.com/ buy ivermectin gastos sa ivermectin pill

  19. Htbnquiet [#]

    viagra mod præstationsangst viagra for the brain provigil

  20. Dnyufloft [#]

    costco pharmacy viagra wechselwirkung citalopram viagra

  21. CntfWeway [#]

    viagra for premature ejactulation cara konsumsi obat viagra

  22. 12 mg ivermectin for sale [#]

    Non-specific Information Here this by-product
    https://ivermectstromect.com ivermectin tablets
    https://ivermectinsts.com ivermectin 12 mg
    https://ivermectstromect.com ivermectin for humans
    https://ivermectinst.com ivermectin for sale
    https://ivermectinstrom.com ivermectin human tablets

  23. ivermectin 6 mg [#]

    General Message Fro this offshoot
    https://ivermectinst.com ivermectin for human tablets
    https://ivermectstromect.com ivermectin human tablets
    https://ivermectstromect.com ivermectin 12 mg tablet for sale
    https://ivermectinsts.com ivermectin for humans for sale
    https://ivermectinsts.com ivermectin 6 mg

  24. prednison [#]

    cheap prednisolone prednisone withdrawal

  25. 12 mg ivermectin for sale [#]

    General Message About this outcome
    https://ivermectinst.com stromectol
    https://ivermectstromect.com ivermectin for humans
    https://ivermectstromect.com ivermectin 12 mg tablet for sale
    https://stromectolivermect.com ivermectin 3 mg
    https://ivermectinstrom.com ivermectin tablets over counter

  26. ivermectin for sale [#]

    Global Information Here this product
    https://stromectolivermect.com ivermectin over the counter
    https://ivermectstromect.com stromectol
    https://ivermectstromect.com ivermectin for sale humans
    https://ivermectinsts.com stromectol ivermectin
    https://ivermectinst.com ivermectin for sale

  27. ivermectin tablets for sale [#]

    Global Information Far this offshoot
    https://ivermectinstrom.com stromectol
    https://ivermectinst.com ivermectin for humans
    https://ivermectinstrom.com ivermectin tablets over counter
    https://ivermectinsts.com stromectol
    https://stromectolivermect.com ivermectin for humans

  28. cheap cialis [#]

    https://cialiswithdapoxetine.com/ cialis pills

  29. ivermectin for sale [#]

    Non-specific Message Here this product
    https://ivermectstromect.com ivermectin tablets
    https://ivermectinsts.com ivermectin 3 mg
    https://ivermectinstrom.com ivermectin 12 mg
    https://stromectolivermect.com stromectol
    https://ivermectstromect.com ivermectin over the counter

  30. ivermectin for sale [#]

    Global Low-down About this by-product
    https://ivermectinsts.com ivermectin 12 mg
    https://ivermectinstrom.com stromectol
    https://ivermectinst.com ivermectin 6 mg
    https://ivermectinstrom.com stromectol
    https://stromectolivermect.com ivermectin 6 mg

  31. ivermectin 12 mg [#]

    Non-specific Message About this offshoot
    https://ivermectstromect.com ivermectin for sale
    https://ivermectinstrom.com ivermectin 12 mg
    https://stromectolivermect.com ivermectin 3 mg
    https://ivermectstromect.com ivermectin for humans for sale
    https://ivermectstromect.com ivermectin 6 mg

  32. provigilreviews [#]

    modafinil reddit modafinil uses

  33. prednisoneuses [#]

    what is prednisone used for prednisone side effects in dogs

  34. isotretinoin side effects [#]

    https://sotretisotretinoin.com/ accutane medication

  35. 12 mg ivermectin for sale [#]

    Non-specific Low-down Far this by-product
    https://ivermectinsts.com ivermectin 6 mg
    https://ivermectstromect.com ivermectin 12 mg tablet for sale
    https://stromectolivermect.com ivermectin 6 mg
    https://ivermectinstrom.com ivermectin over the counter
    https://ivermectinst.com ivermectin 3 mg

  36. ivermectin for sale [#]

    General Information Fro this product
    https://ivermectstromect.com ivermectin 3 mg
    https://ivermectinst.com ivermectin for sale humans
    https://ivermectinst.com ivermectin 3 mg
    https://ivermectstromect.com stromectol
    https://ivermectinsts.com ivermectin tablets

  37. ivermectin for sale [#]

    Accustomed Information About this offshoot
    https://ivermectinsts.com ivermectin tablets
    https://ivermectinsts.com stromectol
    https://ivermectinst.com stromectol
    https://ivermectinsts.com ivermectin 12 mg
    https://ivermectinstrom.com ivermectin over the counter

CSSLab