Home > Software engineering >  I want the link to cover the whole image
I want the link to cover the whole image

Time:12-21

I want the link to cover all images, not only at the center but when you have the mouse over the image.
I don't know how to do this.
Some help, please!

My HTML:

<div >
  <h5><a href="{{seourl}}">{{title}}</a></h5>
  <figure><img src="{{pageThumb}}"/></figure>
</div>

My CSS:

.moduledata{
  position: relative;
  width: auto;
  margin: 0px !important;
  max-width: 380px;
}
.moduledata > h5 {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%,-50%);
}
.moduledata > h5 > a {
  color: #000000;
  font-weight: 300;
  font-size: 38px;
}
.moduledata:hover h5 {
  visibility: visible;
}
.moduledata h5 {
  visibility: hidden;
}

CodePudding user response:

You can wrap your image inside a link so you can click everywhere on the image to follow the link.

#comehere {
  margin-top: 2000px;
}
<a href="#comehere"><img src="https://via.placeholder.com/150x150" alt=""></a>
<div id="comehere">here</div>

  • Related