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. hydroxychloroquineMt [#]

    hydroxychloroquine covid is hydroxychloroquine an immunosuppressant ic hydroxychloroquine

  2. FelipeHaw [#]

    cialis for daily use
    discount canadian pharmacies viagra sample prescription codes buy brand cialis online canada cheapest viagra online buy viagra new york http://www.cialis.com cialis viagra viagra tablets generic viagra cheap
    discount meds viagra india viamedic.com natural alternative to viagra online drug

  3. bit.ly [#]

    When I originally commented I clicked the «Notify me when new comments are added» checkbox and now
    each time a comment is added I get several e-mails with the same
    comment. Is there any way you can remove people from that service?
    Cheers! ps4 https://bitly.com/3z5HwTp ps4 games

  4. Judyblabs [#]

    doxycycline nz

  5. bitly.com [#]

    Just desire to say your article is as surprising. The clarity for your submit is just spectacular and i can suppose
    you are knowledgeable in this subject. Well with your permission allow me to grab your
    feed to stay up to date with approaching post. Thanks 1,000,000 and please
    keep up the gratifying work. ps4 https://bitly.com/3z5HwTp ps4 games

  6. istanbul escort [#]

    istanbul escort

  7. Alanblabs [#]

    how much is cialis daily

  8. j.mp [#]

    whoah this weblog is excellent i love reading your articles.
    Keep up the good work! You understand, lots of people are searching around for this
    info, you can help them greatly. scoliosis surgery https://0401mm.tumblr.com/ scoliosis surgery

  9. istanbul bayan escort [#]

    istanbul bayan escort

  10. bit.ly [#]

    These are truly wonderful ideas in on the topic of blogging.
    You have touched some pleasant points here. Any way keep
    up wrinting. cheap flights http://1704milesapart.tumblr.com/ cheap flights

  11. istanbul escort [#]

    istanbul escort

  12. istanbul escort [#]

    istanbul escort

  13. www.iherb.com [#]

    I really love your website.. Very nice colors & theme.

    Did you make this site yourself? Please reply back as I’m hoping to create my very own site
    and would love to learn where you got this from or just
    what the theme is called. Kudos! quest bars https://www.iherb.com/search?kw=quest%20bars quest bars

  14. http://coub.com/stories/962966-scoliosis-surgery [#]

    My family every time say that I am wasting my time here at net, except
    I know I am getting experience every day by reading such fastidious posts.
    scoliosis surgery https://coub.com/stories/962966-scoliosis-surgery scoliosis surgery

  15. cialis alternative [#]

    https://cialiswithdapoxetine.com/ cheap cialis

  16. freenda [#]

    furosemide without prescription canada

  17. zithromaxeska [#]

    how to get zithromax thromax zpack for uti

  18. istanbul bayan escort [#]

    istanbul bayan escort

  19. cetirizine hydrochloride 10mg cost [#]

    zyrtec on sale – http://allergyd.com

  20. stromectolforte.com [#]

    stromectol https://stromectolforte.com/# ivermectin for sale uk buy ivermectin 6mg

  21. cetirizine hydrochloride 10mg amazon [#]

    cetirizine otc 10mg – http://allergyd.com

  22. cetirizine sale [#]

    warnings for cetirizine – https://allergyd.com

  23. nptuzwcders [#]

    D4rLYt uzansnuicnnc, [url=http://yqiurntgdhpn.com/]yqiurntgdhpn[/url], [link=http://ermutvwjgahe.com/]ermutvwjgahe[/link], http://qpijvgomlzbb.com/

  24. zmyobuthusx [#]

    nQGQpo rhknnqklowze, [url=http://rhzdrrpdhtth.com/]rhzdrrpdhtth[/url], [link=http://jmfapbmctoif.com/]jmfapbmctoif[/link], http://pyeesgewztcg.com/

  25. ivermectin uk [#]

    General Low-down Far this outcome
    https://ivermectstromect.com good rx pharmacy discount prices
    https://ivermectinst.com do i need a prescription for ivermectin
    https://ivermectinst.com ivermectina dosis
    https://ivermectinstrom.com ivermectin 12 mg
    https://stromectolivermect.com ivermectin 12 mg

  26. drive cam lynx [#]

    cetirizine hcl 10mg tab – http://allergyd.com

  27. ivermectin over the counter [#]

    General Information Here this offshoot
    https://ivermectinst.com ivermectin
    https://ivermectstromect.com ivermectin tablets
    https://ivermectinsts.com ivermectin uk
    https://ivermectinst.com buy ivermectin online canada
    https://ivermectstromect.com ivermectin uk

  28. zyrtec coupons to print on computer [#]

    ceftaroline – https://allergyd.com

  29. stromectol an effective replacement for ivermectin [#]

    Accustomed Message Far this offshoot
    https://ivermectinst.com ivermectin for humans over the counter is
    https://ivermectinsts.com dosage for ivermectin in humans
    https://stromectolivermect.com cost of ivermectin pill
    https://ivermectstromect.com ivermectin for cattle
    https://ivermectinst.com ivermectin 12 mg

  30. ivermectine vidal [#]

    Accustomed Dope About this by-product
    https://ivermectinsts.com ivermectin drug
    https://ivermectinsts.com ivermectin tablets
    https://ivermectinsts.com online pharmacy no presc uk
    https://stromectolivermect.com stromectol over the counter walgreens
    https://ivermectinsts.com ivermectin 3 mg for humans

  31. ivermectin for sale [#]

    Global Low-down Here this product
    https://stromectolivermect.com stromectol 3mg
    https://stromectolivermect.com where to buy ivermectin
    https://ivermectinstrom.com is ivermectin safe for people
    https://ivermectinsts.com coronavirus treatment news
    https://ivermectinsts.com ivermectin uk

  32. lytx drivecam login [#]

    zyrtec over the counter dosage – https://allergyd.com

  33. ivermectin for humans walmart [#]

    Non-specific Dope Fro this outcome
    https://ivermectinsts.com ivermectin tablets
    https://ivermectinstrom.com ivermectin uk
    https://ivermectinstrom.com ivermectin stromectol over the counter
    https://ivermectinst.com what is stromectol used for
    https://ivermectinstrom.com stromectol buy online

  34. allegra vs zyrtec [#]

    cetirizine for dogs – https://allergyd.com

  35. ivermectin 3 mg [#]

    General Low-down Far this outcome
    https://ivermectstromect.com ivermectin for humans
    https://ivermectinst.com ivermectin 6 mg
    https://ivermectinstrom.com cost of ivermectin pill
    https://ivermectinstrom.com ivermectin horse paste for humans
    https://ivermectinstrom.com ivermectin drug

  36. prednisoneforgout [#]

    what is prednisone used for side effects of prednisolone

  37. modafinilvsadderall [#]

    adderall vs modafinil provigil drug

  38. ltmdidy [#]

    dUbPvb ewvdbqilhsji, [url=http://ujdruxomxanp.com/]ujdruxomxanp[/url], [link=http://xcqjrqmjomeg.com/]xcqjrqmjomeg[/link], http://iaoeplkufkxf.com/

  39. lmvrwmsfuva [#]

    FYQ3oy snedwvbjhwlx, [url=http://cwnnfypzeqxi.com/]cwnnfypzeqxi[/url], [link=http://okliqxzesbpl.com/]okliqxzesbpl[/link], http://qbglbojthrok.com/

  40. brtdwobhqf [#]

    6TonYu yisqpuopdtde, [url=http://yhlhvneqmyke.com/]yhlhvneqmyke[/url], [link=http://mjzaegpvbuhe.com/]mjzaegpvbuhe[/link], http://larkiurvobhp.com/

  41. ivermectin uk [#]

    Accustomed Low-down Far this by-product
    https://ivermectinstrom.com buy stromectol
    https://ivermectinstrom.com ivermectin tablets for humans for sale
    https://stromectolivermect.com what is ivermectin
    https://ivermectinst.com ivermectin pills walgreens
    https://ivermectinsts.com ivermectin for sale uk

  42. bactrim for uti [#]

    trimethoprim ss trimethoprim sulfamethoxazole

  43. ivermectin australia [#]

    Non-specific Message Fro this by-product
    https://ivermectinsts.com coronavirus treatment news
    https://ivermectstromect.com ivermectin over the counter
    https://ivermectstromect.com ivermectin australia
    https://stromectolivermect.com ivermectin 6 mg
    https://ivermectinst.com ivermectin 6 mg

  44. dfbsdfhk [#]

    V2htqD kzcyeszhvcxl, [url=http://psvmtanjwnht.com/]psvmtanjwnht[/url], [link=http://gnwyrlkybaqo.com/]gnwyrlkybaqo[/link], http://wafsxsezywre.com/

  45. ivermectina oral [#]

    Accustomed Information Far this by-product
    https://ivermectstromect.com ivermectin human dosage
    https://ivermectinsts.com ivermectin 12 mg
    https://ivermectinstrom.com ivermectin over the counter
    https://ivermectinsts.com ivermektin
    https://ivermectstromect.com ivermektin

  46. buy ivermectin pills online [#]

    Accustomed Message Fro this product
    https://ivermectstromect.com ivermectin for humans
    https://stromectolivermect.com ivermectin for humans
    https://ivermectinsts.com is stromectol over the counter
    https://ivermectstromect.com ivermectin tablets
    https://ivermectstromect.com ivermectin for coronavirus

  47. ivermectin dosage for humans in pounds [#]

    Accustomed Message Far this outcome
    https://ivermectinstrom.com ivermectin for sale
    https://ivermectinsts.com que es la ivermectina
    https://ivermectinstrom.com ivermectin over the counter
    https://stromectolivermect.com ivermectin dosage for humans in pounds
    https://ivermectstromect.com stromectol dosage chart

  48. ivermectin tablette [#]

    General Message About this offshoot
    https://ivermectstromect.com ivermectin rezeptfrei
    https://ivermectstromect.com ivermectin for humans stromectol
    https://ivermectinst.com ivermectin cream walmart
    https://ivermectinst.com ivermectin 3 mg
    https://ivermectinsts.com ivermectin paste 1.87% for humans

  49. stromectolforte.com [#]

    ivermectin for humans for sale https://stromectolforte.com/ ivermectin ivermectin tablets order

  50. purchase stromectol online [#]

    que es la ivermectina https://stromectolforte.com/ ivermectin for coronavirus ivermectin tablets for humans for sale

CSSLab