Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6541021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:03:09+00:00 2026-05-25T11:03:09+00:00

An article over on askthecssguy.com shows how to change/invert an image on scroll using

  • 0

An article over on askthecssguy.com shows how to change/invert an image on scroll using fixed backgrounds: http://askthecssguy.com/articles/mike-asks-the-css-guy-about-a-scrolling-trick-with-background-images/

My goal takes this concept further by having the image float over other elements (in this case images).

You can see the result here: http://playground.iamkeir.com/invert-logo/v2/

However, my implementation uses superfluous elements and, so, I was wondering if anyone had any ideas/suggestions of another way to achieve this?

Javascript is certainly an option but I worry it would not be lean/elegant. Someone also suggested using Canvas.

Any ideas welcomed! Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:03:11+00:00Added an answer on May 25, 2026 at 11:03 am

    You can avoid extra markup by using :after CSS pseudo element. Thus, your final markup will look like:

    <ul>
            <li class="light">
                <img src="http://farm3.static.flickr.com/2802/4253151258_7d12da9e1c_z.jpg" />
            </li>
            <li class="dark">
                <img src="http://farm1.static.flickr.com/31/66005536_d1c5afca29_z.jpg?zz=1" />
            </li>
            <li class="light">
                <img src="http://farm4.static.flickr.com/3574/3646151231_0c68f4f974_z.jpg" />
            </li>
            <li class="dark">
                <img src="http://farm4.static.flickr.com/3432/3310214210_813d13c899_z.jpg" />
            </li>
        </ul>
    

    And the altered CSS will be:

    .dark:after,
    .light:after,
    .dark .after,
    .light .after {
        position: absolute;
        display: block;
        content: '';
        top: 0; left: 0;
        height: 100%;
        width: 76px;
        background: transparent url(logo-white.png) no-repeat fixed 0 0;
        z-index: 5;
    }
    
    .dark:after,
    .dark .after {
        background-image: url(logo-black.png);
    }
    

    Notice that there is .after class there. This is to make it work in IE<8, which, sadly, requires to use an expression:

    .dark,
    .light {
        behavior: expression( !this.before ? this.before = this.innerHTML = '<div class="after"></div>' + this.innerHTML : '' );
    }
    

    While using expressions is generally discouraged, this one shouldn’t affect the performance too much, since it is fully evaluated only once, and when the element is created, the condition returns false.

    There is one pitfall, though. If IE8 works in IE8/IE8 mode, the pseudo-elements will be under the images, unless you set negative z-index for the latter, which isn’t always acceptable.

    You can look at working example here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am refering to article at http://www.wintoolzone.com/articles/AuthoringStackWalkerForX86.pdf I am using VC++ 2008. I realize
I was reading an article on Batch Processing in java over at JDJ http://java.sys-con.com/node/415321
I am following the MSDN article located here: http://msdn.microsoft.com/en-us/library/aa302398.aspx My confusion is over the
I was reading over an article that shows some really good information and benchmarks
I am creating a news page and the article is sitting over an image
I've based my work on Phil Haack's article here: http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx I've also looked over
I'm displaying articles on a page. The article titles sometimes spill over onto two
I found this article http://archive.webproasp.com/webproasp-27-20080620CompressingWebResourceaxdtoReduceYourWebsiteSize.html and it explains how to compress axd files (and
http://www.devcurry.com/2010/05/sorting-json-array.html I came across this article, i want few explantions over this article. function
I've read Phil's article ( http://haacked.com/archive/2010/04/15/sending-json-to-an-asp-net-mvc-action-method-argument.aspx ) and still can't figure out how I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.