0

trying to get my code to change the background image to "color.jpg" when "spiral.svg" is being hovered over. I think im getting closer, definitely missing something but not sure what that is!

HTML

   <div class ="spiral">
       <img src="spiral.svg">
    </div>

CSS

img {
    max-width: ???;
    max-height: ???;
}

.spiral:hover {
    background:url('color.jpg') center;
    z-index: some positive number higher than my orig background image?
}


body {
   background:url('orig.jpeg') center;
   z-index: -60;
}
1
  • z-index works when position is specified. Commented Sep 19, 2015 at 21:23

2 Answers 2

1

You may try something like this.

.twitter{
  display:block;
  border:1px solid red;
  width: 30px;
  height:30px;
  background-image:url(http://i.imgur.com/qM7IYaM.png?1);
  background-position:-32px 31px;
  transition:0.1s;
}

.twitter:hover{
   background-position:-32px 63px;  
}
<div href="https://twitter.com/georgevere12" class="twitter">
  
</div>

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

3 Comments

ah yes this works, but im trying to target the <boby> tag. my hover img is actually small and im trying to have it replace the orig background image when being hovered over. starting to think it just might not be possible without js/jquery
you may scale the image using css on hover. By default it will be same as your specified size and on hover scale it to fit on screen with the colored image.
I can get it to change the scale of the image, but this link stackoverflow.com/questions/26822311/… I was reading says it is not possible to target the body tag for this with just using css if im reading it correctly, gonna try some jquery
0

looks like this is not possible with just CSS/HTML however this was the best link i found using a tiny bit of jquery https://stackoverflow.com/a/19770298/5225450

Comments

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.