Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS LESS: Darken color of parent based on child

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #39464
    erow80
    Member

    LESS noob here.

    Here’s some fake markup hopefully illustrating what I’m trying to do:
















    The element will pull the element’s background color and darken it by a certain percentage. It will require the ability to expand out to dozens of colors, otherwise I’d just code them in manually. Plus, this is why I’m using LESS. (See, I’m already trying to convince myself it’s worth it.)

    How do I define a series of colors for different elements, then darken each one by the same value?

    ADDED BONUS: It would be amazing if, say was darker than a certain value, then its font color would lighten, invert, become white, whatever.

    #108277
    Mottie
    Member

    I’m not sure if you can iterate through elements with LESS, but I know SCSS can… check out this CodePen by Chris

    http://codepen.io/chriscoyier/pen/nfpJk

    #108298
    erow80
    Member

    Hm, interesting, but I’m not sure that’s what I’d need even if LESS does allow for this.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘CSS’ is closed to new topics and replies.