Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Hover Colour Change/Vertical Fade

Featured Replies

  • 2 weeks later...

It's done by hiding a background image using a negative position. Then on hover, transitioning it back to its default 0 0 position.

The site you linked to uses a .png image, but you could easily just use a linear gradient.

http://jsfiddle.net/cpejstrk/

Can't believe, even today how many websites are still released that are using images for things that can be easily replicated with a bit of CSS.

We have gradients, shadows, border-radius's even shapes in modern browsers. For more complex shapes we have SVG.

Not sure the above will work because the anchors are initially set to display none, so they don't have a background position to animate from?

You'd be better using keyframes instead.

here's your code updated.

@keyframes bg-slide {
    from { background-position: 0 -2em }
    to { background-position: 0 0 }
}

#menu label{background:linear-gradient(#D4AF37,#D4AF37)no-repeat #101010 0em -2em;border:1px #151515 solid;border-top-left-radius:2.5px;border-top-right-radius:2.5px;color:white;cursor:default;display:block;font-family:candara;font-size:17px;line-height:34px;text-decoration:none;}
#menu a{border-bottom:1px #151515 solid;border-left:1px #151515 solid;border-right:1px #151515 solid;color:white;display:block;font-family:candara;font-size:17px;line-height:34px;text-decoration:none;}
#menu ul{display:inline-block;list-style:none;padding:0px;}
#menu ul ul{display:none;}
#menu li:hover ul{display:inline;}
#menu>ul>li{float:left;width:90px;}
#menu>ul>li:first-of-type,#menu>ul>li:first-of-type label{border-top-left-radius:6.25px 12.5px;}
#menu>ul>li:last-of-type,#menu>ul>li:last-of-type label{border-top-right-radius:6.25px 12.5px;}
#menu>ul>li>ul>li>a{background:linear-gradient(#D4AF37,#D4AF37)no-repeat #101010 0em -2em;border-bottom-left-radius:6.25px 12.5px;border-bottom-right-radius:6.25px 12.5px;color:white;}
#menu>ul>li:first-of-type>ul>li a{border-bottom-left-radius:6.25px 12.5px;}
#menu>ul>li:last-of-type>ul>li a{border-bottom-right-radius:6.25px 12.5px;}

#menu li a:hover  { animation: bg-slide 0.25s 0.2s forwards }
#menu li:hover label { animation: bg-slide 0.25s forwards; color: black }

If you want one fluid animation change #menu li a:hover to #menu li:hover a

 

 

Can't believe, even today how many websites are still released that are using images for things that can be easily replicated with a bit of CSS.

We have gradients, shadows, border-radius's even shapes in modern browsers. For more complex shapes we have SVG.

 

I know. People who still use images for buttons :( just means a lot more work if changes are needed.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.