I want to hide last divider between comments using css. Code is below.
<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>
I am generating that in rails view:
<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>
I tried that:
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
}
Goal is how to do that without using ruby in view.
The :last-child pseudoclass still cannot be reliably used across browsers. In particular, Internet Explorer versions < 9, and Safari < 3.2 definitely don't support it, although Internet Explorer 7 and Safari 3.2 do support :first-child, curiously.
Your best bet is to explicitly add a last-child (or similar) class to that item, and apply div.last-child instead.
or you could use some Javascript.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With