0

我在 CSS 上很弱,无法破解。当用户将鼠标悬停在图像上时,overlay-div 类被激活。但是因为它包含在一个 link_to 函数中,所以 form_for 按钮不起作用。玩 z-indexes 并没有解决它。我怎么能破解这个?

风景:

<%= 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;
}
4

0 回答 0