Reputation: 309
i want to make overlay on hover button, i made it but learn more link did'nt appear when i hover over the button container, so i tried change its position as show in code below and it's appear, but it's not clickable, what wrong in my code or how can i show the clickable link in another way?
.container{
width:300px;
height: 300px;
background-color: red;
position: relative;
margin: auto;
}
img{
display: block;
width: 100%;
height: 100%;
}
.overlay{
background-color: grey;
opacity: 0.5;
width: 3%;
height: 100%;
position: absolute;
top:0;
right: 0;
transition: width 0.6s ease-out;
}
.container:hover .overlay{
width: 100%;
}
.overlay a{
color: white;
display: block;
text-decoration: none;
border-bottom: 5px;
margin-top: 9px;
}
#button-container{
visibility: hidden;
width: 120px;
height: 30px;
position: relative;
background-color: black;
color: white;
margin:70px auto;
text-align: center;
line-height: 2em;
transition: all 250ms ease-in-out;
}
#button-container:after{
display: block;
content: "";
width: 15px;
height: 30px;
background-color: white;
position: absolute;
right: 0;
top: 0;
}
.container:hover #button-container{
visibility: visible;
}
#button-container:hover::after{
width: 100%;
}
#learn-more{
transition:all 250ms ease-in-out;
}
#button-container:hover #learn-more{
display: block;
height: 30px;
width: 120px;
color:black;
z-index: 1;
position: absolute;
top:0;
margin: 0px auto;
}
<body>
<div class ="container">
<img src="3.jpeg" alt="">
<div class="overlay">
<a href="#" class="social">facebook</a>
<a href="#" class="social">twitter</a>
<a href="#" class="social">instagram</a>
<div id="button-container">
<a id="learn-more" >learn more</a>
<!-- <div id="button-overlay"></div> -->
</div>
</div>
</div>
</body>
how can i do it in another way?
Upvotes: 0
Views: 346
Reputation: 44
replace this:
<a id="learn-more" href="#">learn more</a>
because you need href
to link become clickable and if you add href=""
page will reload
Upvotes: 1
Reputation: 109
you have to put href attribute for your a tag
<a id="learn-more" href="YOUR_LINK"></a>
Upvotes: 1