我想使用 css 隐藏评论之间的最后一个分隔符。代码如下。
<div id="question_comments" class="comments_container">
<div class="comment">
<div class="comment_details">
<div>
<p>Comment1</p>
</div>
</div>
</div>
<div class="hr-comment"></div>
<div class="comment">
<div class="comment_details">
<div>
<p>Comment2</p>
</div>
</div>
</div>
<div class="hr-comment"></div>
<div id="question_comment">
<form> ... </form>
</div>
<div class="clear"></div>
</div>
我在 Rails 视图中生成它:
<div id="question_comments" class="comments_container">
<% @question.comments.order("created_at ASC").each do |comment| %>
<%= render :partial => "questions/comment", :locals => { :comment => comment } %>
<div class="hr-comment"></div>
<% end %>
<%= render :partial => 'new_comment', :locals => {:targit => @question, :answer => nil} %>
<div class="clear"></div>
</div>
我试过了:
div.hr-comment {
background:url(hr-background.gif) repeat-x;width:100%;height:2px;margin-top:7px;margin-bottom:7px;width:310px;
}
.hr-comment:last-child {
display: none
}
目标是如何在不使用 ruby 的情况下做到这一点。