Jump to content
Sign in to follow this  
KillZoneZ

Background image fade

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Not sure what your images are since the URL doesn't work, but if it's just a gradient or something than you can use CSS to create it.

  • Like 1

Share this post


Link to post
Share on other sites

Good idea, because it seems background gradients aren't supported by transition either.

Share this post


Link to post
Share on other sites

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.

Sign in to follow this  

×
×
  • 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.