Jump to content

Background image fade


KillZoneZ

Recommended Posts

I want to make so when the user hover's the button, it fades away to a new background-image. I managed to make it change the background-image, but the time it takes to change itself is not what i want it to be. Even if i put 6s it will still change the background-image instanstly. Here's my code:

#SignUpButton {
	font-family:'Oxygen',sans-serif;
	color:#F7F7F7;
	-webkit-border-radius: 3px;
	-moz-border-radius: 3px;
	border-radius: 3px;
	margin-top:3%;
	position:relative;
	height:40px;
	width:40%;
	background-image:url("http://s8.postimg.org/o723mxtdf/Button_Dark.png");
	margin-left:30%;
	margin-right:30%;
	border:none;
        transition:6s;
}

#SignUpButton:hover {
	background-image:url("http://s11.postimg.org/6bkzpzav5/Button_Main.png");
}

Thanks

Link to comment
Share on other sites

You can't animate the background-image property with straight css (see here -scroll down for 'background'). However, you can layer images over one another and fade the top one in and out on hover. Check here - good information on cross-fading images, including keyframe, timed, and delayed information.

  • Like 1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.