Author Topic: How to change image depending on background?  (Read 218 times)

0 Members and 1 Guest are viewing this topic.

Offline liamloveslearningTopic starter

  • Enthusiast
  • Gender: Male
    • View Profile
How to change image depending on background?
« on: February 05, 2010, 11:12:28 AM »
Hey everyone,

Has anybody an idea on how econsulting have done this with there logo, if you scroll down far enough you see it changes colour depending on the background, so it goes from transparent to solid, is this JavaScript or?

Heres the culprit
http://econsultancy.com/reports/search-engine-optimization-seo-best-practice-guide
everyone starts somewhere!

Offline haku

  • Guru
  • Fanatic
  • *
  • Old Man
    • View Profile
Re: How to change image depending on background?
« Reply #1 on: February 05, 2010, 07:40:14 PM »
It's actually two different images, and they are using:

Code: [Select]
background-attachment:fixed
on each of the images. The way this CSS selector works is like having an element with a fixed position, but it's only visible when the element that it's placed inside is visible in that location. So at the top of that document, the image is in the head, so its visible. Then as you scroll, the head becomes non-visible (by scrolling up) and so the image disappears, but the second image becomes visible, because the section which it is in becomes visible in that spot.

Offline liamloveslearningTopic starter

  • Enthusiast
  • Gender: Male
    • View Profile
Re: How to change image depending on background?
« Reply #2 on: February 06, 2010, 03:50:32 PM »
brilliant haku, makes perfect sense! thanks
everyone starts somewhere!

Offline lAZLf

  • Enthusiast
    • View Profile
Re: How to change image depending on background?
« Reply #3 on: February 08, 2010, 08:34:04 PM »
What haku said works incredibly (I implemented it on my own site). Also if you noticed, the image is a link, I would assume they just made a link with a set height and width with its position set to absolute and placed it over the background image.

Offline liamloveslearningTopic starter

  • Enthusiast
  • Gender: Male
    • View Profile
Re: How to change image depending on background?
« Reply #4 on: February 09, 2010, 03:58:34 AM »
love the effect lAZLf, it works well!
everyone starts somewhere!

PHP Freaks Forums

« on: »

Tired of these ads? Purchase a supporter subscription to get rid of them.