0

I am getting an error at the background-repeat attribute in actual the image has to change whenever the mouse pointer hovers over the image but it is showing the test case is failed. Tried to change it with background: "imgfile.jpg" no-repeat; but still same error is recurring. Help me with this. Thank you.

Here is the description about the code Create a page that will display an image changing effect on mouse over in a file named imgeffect.html.

Initially the page would get displayed as below with only an image of apple (apple.jpg : with no-repeat attribute set to it in the same line )

apple

When we mouse over this image a transition effect on the image needs to happen, changing the image from apple to mango (mango.jpg : with no-repeat attribute set to it in the same line )

The page then should display :

mango

Create a webpage using the fields below:

A tag, with "step1" as class.

The width and height are 250px and 300px respectively. Initially it must be appear with the image "apple" with 100px margin. For the transisition, change the CSS3 properites of the div tag named as "step1" to

Width as 350px, height as 300px and change the image from apple to mango with the same margin value.

<!DOCTYPE html>
<html lang="en">
<head>
<title>Change Image on Hover in CSS</title>
<style type="text/css">
.step1
{
width: 250px;
height: 300px;
background-image: "apple.jpg";
background-repeat: no-repeat;
margin:100px;
}
.step1:Hover
{
width:350px;
height:300px;
background-image: "mango.jpg";
background-repeat: no-repeat;
}
</style>
</head>
<body>
<div class="step1"></div>
</body>
</html>

testcase-failed-image

1

1 Answer 1

2

A simple change can help

simply change your code from

background-image: "apple.jpg"; 

to

background-image: url("apple.jpg");

correct it to mango.jpg too.

As an easier format you can also put it in this way:

background: url("mango.jpg") no-repeat;

in this way you can put all the background properties in single line.

Sign up to request clarification or add additional context in comments.

4 Comments

"in this way you can put all the background properties in single line." perhaps show how to do that using the OP's provided sample code and the mouseover called for
@MarkSchultheiss sorry sir. can you make it clear. i didnt understand "what to show using the sample code".
@MunnaluriVishalpagnGeCtKY glad to know its working.
he is saying to replace background-image attribute to background in which while the background-image carries only the image attribute and the background can handle the image and also some other requests like in this case no-repeat

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.