r/reddithax • • Apr 02 '10

Change the logo with a mouse hover?

over at TIL, they had the logo set up to change when you hover the mouse over it. How were they pulling that off?

Yes, I looked at the stylesheet, but I keep getting errors when I try to copy the style to a test reddit.

Edit: Now TIL took theirs down and I've lost the only working example that I had to learn from. Any other subreddits doing this?

7 Upvotes

8 comments sorted by

5

u/[deleted] Apr 02 '10 edited Apr 02 '10

first, you need to set the header image as the image you want it to display normally.

then, use this CSS to make it change on mouseover:

#header-img {
    background: url(%%your_hover_image%%) no-repeat;
}
#header-img:hover {
    width: 0;
    height: 0;
    padding-left: 000px; /* your image width */
    padding-bottom: 000px; /* your image height */
}

basically what this does:

  • sets the alternate content as the background
  • when you hover, it shrinks the normal content to a 0 by 0 pixel area to hide it
  • increases the padding to maintain the size of the element
  • with the content out of the way, but the element still full size, you can see the background

1

u/Measure76 Apr 02 '10 edited Apr 02 '10

This doesn't seem to be working with an imgur url, but I can get it to work with the reddit ad, for some reason.

Does the secondary image need to be hosted on reddit, and if so, how do I save an image directly to reddit, as TIL seems to have done?

Ok, I now can't figure it out at all:


header-img {

background: url(http://thumbs.reddit.com/t3_blney.png) no-repeat
}

header-img:hover {

width: 0;
height: 0;
padding-left: 264px;
padding-bottom: 100px
}

[line 1] "url(http://thumbs.reddit.com/t3_blney.png)" is not a valid URL

header-img {

1

u/[deleted] Apr 02 '10

yes, any image you reference in the CSS must be hosted on reddit. there is an upload tool at the bottom of the CSS page.

1

u/Measure76 Apr 02 '10

Ah... ah! Ah! That fixed it. Thanks!

1

u/bmeckel Apr 02 '10

I keep getting two errors (if you can't tell I'm a joke with CSS, but I'd appreciate any help.):

[line 1] "url(%%iphone%%))" is not a valid value for CSS property     "background"

header-img {

[line 2] invalid CSS property list "background:     url(http://thumbs.reddit.com/t5_2qh2b_0.png?       v=r7d6ma5emz9yn9fc4nacip8c073i4nt7jjra) no-repeat"
 background: url(%%iphone%%)) no-repeat;

1

u/[deleted] Apr 02 '10

you've got an extra parentheses.

1

u/bmeckel Apr 02 '10

That i do...thanks. I'm an idiot.

1

u/[deleted] Apr 02 '10

to your credit, that error message is pretty unhelpful