用户将鼠标悬停在glyphicon-globe
图片上,在其后面有一个类似按钮和评论表单。当用户去点击按钮或评论表单什么也没有发生。我怎样才能点击全球背后的东西?如何让鼠标点击后悬停?
视图
<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;
}
没有悬停
悬停
由于'Z-index'在'图像foreground' ID你是不是能够点击元素 –
如果要变成可点击只有一个元素您可以捕获前端对象的单击,使该对象消失,然后在需要的元素中生成单击。 –
谢谢@pitabasprathal。问题在于我把z-index设置为负值,但是随后地球图像闪烁,导致我癫痫发作 –