A user hovers over glyphicon-globe
image and behind it lies a like button and a comment form. When a user goes to click on the button or the comment form nothing happens. How can I make clickable what lies behind the globe?
view
<div class="image-container">
<span class="glyphicon glyphicon-globe" style="font-size: 7em; color: white; text-align: center; width: 100%; background-color: #446CB3; border-radius: 4px; padding: 19%;" id="image-foreground"></span>
<div class="text-wrapper">
<div class="like-button">
<%= link_to like_challenge_path(:id => @challenge.id), class: "btn", method: :post do %>
<span class='glyphicon glyphicon-thumbs-up'></span> Like
<% end %>
</div>
<div class="text-background">
<%= render "comments/form" %>
</div>
</div>
</div>
css
.image-container {
position: relative;
height: auto;
#image-foreground {
position: absolute;
z-index: 2;
opacity: 1;
&:hover {
opacity: 0;
}
}
}
.text-wrapper {
opacity: 1;
}
no hover
hover
Here was the trick that worked:
you could do on hover display the blue screen as none.
it that what you wanted ?
There's two ways I'd try. So you know, giving an element
opacity: 0;
won't make it disappear completely. It is still there in position but not able to be seen. To have an element removed also use bothopacity: 0;
andvisibility: hidden
in your&:hover
action.The second way you could do it is stick with
opacity: 0
but also setz-index: 0
(or any number below the z-index of the underlying layers. You have the hover working nicely but because it has a higherz-index
than the underlying layers, it is still technically sitting on top of them and covering them, making them unclickable.Hope that helps
Also a side note to the answer below, one of the answers here suggested using
display: none
in yourhover
action.display: none
doesn't work for this as once an element is set todisplay: none
, it is no longer there, not part of the DOM and so breaks the hover action.