Click here to Skip to main content
15,891,248 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a background image and another image positioned on top of it, which is supposed to move to the right when I hover over the background image. Here is the code I have so far:
HTML
HTML
<div class="delivery_background"><div class="delivery_car"></div></div>

CSS
.delivery_background {
	background: url(../images/icons/delivery_animation.png);
	width: 1082px;
	height: 172px;
	margin-left: auto;
	margin-right: auto;
	border-radius: 5px;
	margin-bottom: 15px;
}

.delivery_car {
	position: relative;
	background: url(../images/icons/delivery_car.png);
	left: 10px;
	top: 75px;
	width: 120px;
	height: 80px;
	transition: left 10s ease;
}

.delivery_car:hover {
	position: relative;
	background: url(../images/icons/delivery_car.png);
	left: 750px;
	top: 75px;
	width: 120px;
	height: 80px;
	transition: left 3s ease;
}

I want the car to move when the background div is hovered over. Thanks!
So far the car moves only when you hover over it.

Here is a live example: EXAMPLE
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900