Triángulos con CSS: LESS Mixin

10/Jun/2014 168

Crear formas geométricas con puro CSS y 1 elemento HTML ha sido una tarea creada hace años ya y que tiene recopilaciones varias de métodos y usos. Personalmente para crear triángulos con CSS uso un generador genial que espero nunca lo bajen: CSS triangle generator.

A raíz de su constante uso, creé un mixin para LESS que me permite crear triángulos equilátero, isósceles y escaleno con sólo variar los valores de ancho/alto y dirección:

Uso

Llama el mixin en tu sentencia CSS y entrégale los valores que necesitas:

.triangle(direccion,ancho,alto,color);

Dirección: valores

  • top
  • bottom
  • left
  • right
  • topright
  • topleft
  • bottomright
  • bottomleft

Ejemplo: básico

@tamano: 50px;
@color: red;
.basico {
  .triangle(bottomright,@tamano,@tamano,@color);
}

Ejemplo: avanzado

@tamano: 50px;
@color: red;
.avanzado {
  width: @tamano*2;
  height: @tamano;
  line-height: @tamano;
  background-color: @color;
  position: relative;
  &:after {
    position: absolute;
    left: 0;
    top: -@tamano;
    .triangle(top,@tamano,@tamano,@color);
  }
  &:before {
    position: absolute;
    left: 0;
    top: @tamano;
    .triangle(topleft,@tamano*2,@tamano*2,@color);
  }
}

Ver en GitHub

*actualización: Gracias a Félix Ortega por traducir el mixin a SASS:

Comentarios

  1. Mgresg [#]

    clomiphene online 100mg – clomid no prescription order clomiphene

  2. Yanruy [#]

    clomid for sale – generic clomid over the counter clomiphene online

  3. hydroxychloroquine uses [#]

    hydrochloroquin https://plaquenilx.com/# hydroxychloroquine malaria

  4. Afebui [#]

    cheap viagra overnight – sildenafil cost viagra 75 mg price

  5. keto delivery meals [#]

    keto diet plan pdf

  6. Mlhaqd [#]

    viagra 15 mg – viagra canadian pharmacy prices ordering viagra

  7. Vvnmbr [#]

    compare pharmacy prices – cialis 5mg cost cialis pharmacy cost

  8. Dmeqom [#]

    tadalafil soft 20 – cialis online order canada 5mg cialis best price

  9. keto diet poop [#]

    keto and intermittent fasting https://ketodietplanus.com/

  10. Npakhx [#]

    ivermectin uk – covid and ivermectin purchase ivermectin

  11. Ogwczk [#]

    buy liquid ivermectin – fda ivermectin ivermectin buy uk

  12. KevinWet [#]

    dallas gay dating
    gay muslim dating london
    dating sites for gay singles

  13. Itfyvm [#]

    online casino no deposit bonus – casinos online online casino usa real money

  14. Xlulgx [#]

    empire casino online – chumba casino casino slots gambling

  15. good gay dating site that work [#]

    gay and bi dating sites https://gaychatgay.com/

  16. 10 gay dating disasters [#]

    gay executive dating https://gaydatingzz.com/

  17. gay dating in saudi arabia [#]

    gay 15 year old dating site https://gaychatrooms.org/

  18. Mkruur [#]

    erectile dysfunction age – over the counter ed pills at walgreens what is erectile dysfunction

  19. Tnirym [#]

    what blood pressure medication does not cause erectile dysfunction – new ed pill ed pill

  20. Qrkpjn [#]

    prednisone for sale – prednisone no rx buy prednisone online no prescription

  21. Mdehyx [#]

    steroid prednisone – how much is prednisone 10 mg prednisone 60 mg

  22. KevinWet [#]

    gay dating hiv
    gay and lesbian dating website
    gay dating ads in biloxi

  23. Vwtmus [#]

    viagra 100mg online in india – viagra 120mg where to buy viagra over the counter

  24. Ptdeqg [#]

    viagra sildenafil 100mg – canada rx sildenafil viagra online pharmacy usa

  25. Lea [#]

    Hello There. I found your blog using msn. This is a very neatly
    written article. I’ll make sure to bookmark it and come
    back to learn extra of your useful information. Thank you for the post.
    I’ll definitely comeback.

  26. web hosting off [#]

    Excellent post. I was checking continuously this weblog and I am inspired!

    Extremely helpful information particularly the last section :
    ) I care for such information much. I used to be looking for
    this particular information for a long time.

    Thanks and best of luck.

  27. RodolfoZowly [#]

    hydroxychloride medicine side effects for hydroxychloroquine hydroxchloroquin

  28. is web hosting [#]

    If some one desires to be updated with hottest technologies therefore
    he must be pay a visit this site and be up to date everyday.

  29. http://j.mp/ [#]

    This post is in fact a pleasant one it helps new internet visitors, who are wishing in favor of blogging.

  30. fat fetish gay dating [#]

    gay dating in denver https://gayonlinedating.net/

  31. HenryUnfiP [#]

    gay girl dating website
    casual gay dating
    does match.com allow gay dating

  32. gay dating grad student [#]

    lds gay dating https://gay-singles-dating.com/

  33. dating a mormon gay guy [#]

    ai gay dating https://dating-gaym.com/

  34. gay speed dating atlanta [#]

    gay dating jd.shirley.3 https://datinggayservices.com/

  35. gay men social dating sites [#]

    gay dating game site https://gayedating.com/

  36. ivermectin for humans dosage [#]

    can you buy stromectol over the counter Triangulos con CSS: LESS Mixin | CSSLab | Laboratorio de ideas web http://ivermectin1.com/ generic stromectol

  37. quest bars their [#]

    If you are going for most excellent contents like I do,
    just pay a visit this web page everyday for the reason that it presents feature contents, thanks quest bars http://j.mp/3jZgEA2 quest bars

  38. stromectol [#]

    acquistare stromectol Triangulos con CSS: LESS Mixin | CSSLab | Laboratorio de ideas web http://ivermectin1.com/ ivermectin tablets

  39. gay dating connecticut [#]

    gay dating is impossible https://gaydatinglosangeles.com/

  40. bitly.com [#]

    Hello, all is going fine here and ofcourse every one is sharing data,
    that’s truly excellent, keep up writing. scoliosis surgery
    https://0401mm.tumblr.com/ scoliosis surgery

  41. pure dating site gay straight [#]

    dating a bodybuilder gay https://gaydatingcanada.com/

  42. app.gumroad.com [#]

    Do you have a spam issue on this site; I also am a blogger,
    and I was wondering your situation; we have developed some nice practices and we are looking
    to swap strategies with other folks, please shoot me an email if interested.
    asmr https://app.gumroad.com/asmr2021/p/best-asmr-online asmr

  43. http://bitly.com/3hkp4jI [#]

    Why viewers still make use of to read news papers when in this technological world everything is accessible on web?

    cheap flights http://1704milesapart.tumblr.com/ cheap flights

  44. hydroxychloroquineMt [#]

    chloroquine prophylaxis buy chloroquine online hydroxycloriquin

  45. coub.com [#]

    Thank you for the auspicious writeup. It in fact was a
    amusement account it. Look advanced to more added agreeable from you!

    However, how can we communicate? scoliosis surgery https://coub.com/stories/962966-scoliosis-surgery scoliosis surgery

  46. bit.ly [#]

    This paragraph provides clear idea in support of the new users of blogging,
    that truly how to do blogging and site-building. ps4
    https://j.mp/3z5HwTp ps4 games

  47. HenryUnfiP [#]

    gay dating younger older
    gay dating missoula, mt
    tooele gay dating

  48. zithromaxeska [#]

    zithromax 250mg tablet uti zithromax zithromax tablet

  49. www.iherb.com [#]

    Hey there would you mind letting me know which web host you’re using?

    I’ve loaded your blog in 3 different web browsers and I must say this blog loads a lot quicker then most.

    Can you suggest a good internet hosting provider at
    a reasonable price? Thank you, I appreciate it! quest bars https://www.iherb.com/search?kw=quest%20bars quest bars

  50. zithromaxeska [#]

    what is zithromax 250 mg used for zithromax 500 zithromax treatment

CSSLab