Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I love the image hover effect style of these pictures but I want to make each picture a link to another page but when I do that using
HTML
<a href... 
it changes the style - instead of the pictures getting bigger when you hover over it, it changes, the pictures are already big and there is no writing on them.


Does anyone know how I can change it so the pictures are links with the same hover effect?

What I have tried:

This is the code I am doing, as you can see i have put links in for the first two pictures but I want them to be the style of the second two pictures---

HTML
 <pre>  
 <div class="container-fluid">
  <div class="box ">
    <a href="https://thehealthyminduk.000webhostapp.com/" target="_blank">  
    <img src="https://source.unsplash.com/1000x800"></a>  
      
    <span>CSS</span>
  </div>
  <div class="box">
       <a href="https://thehealthyminduk.000webhostapp.com/" target="_blank"> 
    <img src="https://source.unsplash.com/1000x802">
           <span>Image</span></a>
  </div>
  <div class="box">
    <img src="https://source.unsplash.com/1000x804">
    <span>Hover</span>
  </div>
  <div class="box">
    <img src="https://source.unsplash.com/1000x806">
    <span>Effect</span>
  </div>
</div>



Css-

CSS
.container-fluid {
  display: flex;
  width: 100%;
  padding: 4% 2%;
  box-sizing: border-box;
  height: 80vh;
}

.box {
  flex: 1;
  overflow: hidden;
  transition: .5s;
  margin: 0 2%;
  box-shadow: 0 20px 30px rgba(0,0,0,.1);
  line-height: 0;
}

.box > img {
  width: 200%;
  height: calc(100% - 10vh);
  object-fit: cover; 
  transition: .5s;
}

.box > span {
  font-size: 2.8vh;
  display: block;
  text-align: center;
  height: 10vh;
  line-height: 2.6;
}

.box:hover { flex: 1 1 50%; }
.box:hover > img {
  width: 100%;
  height: 100%;
}
Posted
Updated 5-Sep-19 4:49am
v2

1 solution

Consider posting on these CP forums: [^], [^]

This a C# forum.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900