Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 0
ConnorSW

Image Hover not working on Mobile

Question

I have used coding to achieve a hover over effect that changes the image to another image when hovered over, but for some reason none of the images display on the mobile version. and my coding knowledge isnt good enough to know if this is a coding error or just squarespace not allowing it.

 

The code below is the one im using:

 

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Image Swap on Hover with CSS</title>
<style>
    .card {
        width: 350px;
        height: 170px;
        position: relative;
        display: inline-block;
    }
    .card .img-top {
        display: none;
        position: absolute;
        top: 0;
        left: 0;
        z-index: 99;
    }
    .card:hover .img-top {
        display: inline;
    }
</style>
</head>
<body>
    <a href="http://www.google.co.uk/"><div class="card">
        <img src="https://static1.squarespace.com/static/5e2ec9142b320c36322b1291/t/5e3d336e0e665361c45a7957/1581069167346/mtss-0858R-f.jpg
" alt="Card Back">
        <img src="https://static1.squarespace.com/static/5e2ec9142b320c36322b1291/t/5e3d33629d7664785ea5a5ce/1581069154983/mtss-0858r.jpg" class="img-top" alt="Card Front">
    </div></a>
</body>
</html>

Share this post


Link to post

3 answers to this question

Recommended Posts

  • 0
22 hours ago, tuanphan said:

CSS hover won't work on Mobile. You need to use JavaScript in this case (complicated)

its less about having the effect on the mobile, but the front image doesn't even show on the mobile, it shows no image whatsoever. It works when i first put the coding in and then the image disappears over time

Share this post


Link to post
  • 0
On 3/6/2020 at 6:52 AM, ConnorSW said:

The code below is the one im using:

Where are you placing this code? Why is it an entire HTML document?

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment


×
×
  • Create New...