Treehouse: Grow your CSS skills. Land your dream job.

Dynamically derive CSS colours from image

  • # June 19, 2010 at 6:39 am

    Hi all, first post here so be gentle!

    I’m working on a site with a ‘featured’ post atop the home page. My page has a thin border at the top, and I’d love to be able to define the colour value of that border dynamically, from the dominant colour of the image in that featured post.

    Anyone know if that’s possible?



    # June 19, 2010 at 8:12 am

    Crikey! That sounds like a massive challenge!

    It would probably require the use of JavaScript to alter the colour after the page loads, or using PHP to create a dynamic stylesheet. Actually getting the colour from the image sounds difficult, but I’m sure it’s not impossible

    # June 23, 2010 at 8:18 pm

    I would suggest to find the dominant color on the serverside ( php, ruby, asp, whatever ), and set the border color as inline css in this case. AND i would suggest the color-calculation to be done when image gets uploaded.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.