Search code examples
htmlcssmobile-website

Remove image link in mobile screen


I have a clickable image on my desktop website theme which showed on mobile screens. I’ve managed to remove the image with the following code but it has left a ‘ghost’ link which users don’t see but if touched takes them to the linked page:

In footer.tpl

<div id="footer">
<div class="column">

<a href="http://mywebsite.com/delivery" id="test"></a> 

In stylesheet.css

#test {

  @media screen and (max-width: 480px) { image display: none; }   

  background-image: url('../image/myimage.png');
  background-repeat: no-repeat;
  position: absolute;
  margin-top: 10px;
  margin-left: 20px; 
  width: 75px;
  height: 75px;

Is there any way the link could also be removed? Thanks in advance.


Solution

  • Give your element a display:none; on the media query.

    #test {
      display: block;
      background-image: url('../image/myimage.png');
      background-repeat: no-repeat;
      position: absolute;
      margin-top: 10px;
      margin-left: 20px; 
      width: 75px;
      height: 75px;
      background: whitesmoke; /** Testing purposes **/
    }
    
    @media all and (max-width: 480px) {
        .hide {
          display: none;
        }
    }
    <div id="footer">
    <div class="column">
    <a href="http://mywebsite.com/delivery" id="test" class="hide"></a>