I have this problem where I have set an image to display another image when the mouse hovers over, however the first image still appears and the new one doesn't change height and width and overlaps the other one. I'm still pretty new to HTML/CSS so I may have missed something simple. Here is the code:
<img src="LibraryTransparent.png" id="Library">
#Library { height: 70px; width: 120px; } #Library:hover { background-image: url('LibraryHoverTrans.png'); height: 70px; width: 120px; }
The following code will help to change the image automatically at a certain time interval. setInterval(function() { nextSlide() }, 5000); ➤ I have instructed that the condition of nextSlide should be effective every 5 seconds. That means the images will change every 5 seconds .
Yes, you can use CSS content . To switch between the normal text and "Reply!", put the normal text in a span and hide that when hovering. button { width: 6em } button:hover span { display: none } button:hover:before { content: "Reply!" }
Another option is to use JS:
<img src='LibraryTransparent.png' onmouseover="this.src='LibraryHoverTrans.png';" onmouseout="this.src='LibraryTransparent.png';" />
One solution is to use also the first image as a background image like this:
<div id="Library"></div>
#Library { background-image: url('LibraryTransparent.png'); height: 70px; width: 120px; } #Library:hover { background-image: url('LibraryHoverTrans.png'); }
If your hover image has a different size, you've got to set them like so:
#Library:hover { background-image: url('LibraryHoverTrans.png'); width: [IMAGE_WIDTH_IN_PIXELS]px; height: [IMAGE_HEIGHT_IN_PIXELS]px; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With