我在CSS上相当弱,无法解决这个问题。当用户将鼠标悬停在图像上时,将激活overlay-div类。但是因为它包含在link_to函数中,所以form_for按钮不起作用。使用z-index并没有解决它。我怎么能破解这个?
观点:
<%= link_to activity_path(activity), class: "img-overlay" do %>
<%= image_tag activity.image_path %>
<div class="img-overlay-div">
<h4>
<%= activity.title %>
</h4>
<%= form_for(current_user.activity_relationships.build(activity_followed_id:
activity.id), remote: true) do |f| %>
<div><%= f.hidden_field :activity_followed_id %></div>
<%= f.submit "Add to My Activities", class: "b-item" %>
<% end %>
</div>
<% end %>
CSS
.img-overlay {
position: relative;
display: block;
z-index: 0;
}
.img-overlay-div {
background: rgba(0, 0, 0, 0.7);
color:white;
cursor: pointer;
display: block;
opacity: 0;
height: 100%;
left: 0;
position: absolute;
top: 0px;
width: 100%;
z-index: 100;
min-height: 170px;
}
.b-item {
line-height: 40px;
background: url("../assets/button02.jpg") top left repeat-x;
position: absolute;
bottom: -8px;
left: 33px;
width: 150px;
z-index: 1;
color: rgba(0,0,0,0.6);
font-family: 'OpenSansRegular';
box-shadow: 0 2.5px 1px rgba(0,0,0,0.25);
font-weight: normal;
text-transform: uppercase;
font-size: 15px;
padding: -20px;
border-radius: 2px;
border: 1px solid #333333;
text-shadow: 0 1px rgba(255, 255, 255, 0.25);
}
.b-item:hover {
background: url("../assets/button02.jpg") top left repeat-x;
color: rgba(0,0,0,0.6);
border: 1px solid #333333;
box-shadow: 0px 2.5px 15px 5px rgba(255, 255, 190, .75);
z-index: 1;
}