将css类应用于没有js的div
我在我的应用程序中递归地显示一些嵌套注释,但在没有嵌套注释时遇到了应用特定类的挑战。仅当嵌套的\u命令大于0时,如何将类将css类应用于没有js的div,css,ruby-on-rails,Css,Ruby On Rails,我在我的应用程序中递归地显示一些嵌套注释,但在没有嵌套注释时遇到了应用特定类的挑战。仅当嵌套的\u命令大于0时,如何将类sole干净地应用于我的div条目 def horizontal_tree_for(comments) comments.map do |comment, nested_comments| entry(comment) + (nested_comments.size > 0 ?
sole
干净地应用于我的div条目
def horizontal_tree_for(comments)
comments.map do |comment, nested_comments|
entry(comment) +
(nested_comments.size > 0 ?
content_tag(:div, horizontal_tree_for(nested_comments), class: "branch") +
"</div>"
: "</div>")
end.join.html_safe
end
def entry(comment)
"<div class='entry' **conditional sole class**><span class='label'> #{comment.name} </span>"
end
def水平树(注释)
comments.map do | comment,嵌套的| comments|
条目(备注)+
(嵌套的注释大小>0?
内容标签(:div,水平树(嵌套注释),类:“分支”)+
""
: "")
end.join.html_safe
结束
def条目(注释)
“#{comment.name}”
结束
此样式仅适用于具有子元素的元素:
.empty{
背景色:黑色;
高度:100px;
}
div:not(:空){
背景色:红色!重要;
}
此样式仅适用于具有子元素的元素:
.empty{
背景色:黑色;
高度:100px;
}
div:not(:空){
背景色:红色!重要;
}
按照注释中的建议,只需编写类即可 伪代码:
"<div class='entry (nested_comments.size > 0 ? "sole" : "")'>
<span class='label'> #{comment.name} </span>"
”
#{comment.name}”
按照注释中的建议,只需编写类即可
伪代码:
"<div class='entry (nested_comments.size > 0 ? "sole" : "")'>
<span class='label'> #{comment.name} </span>"
”
#{comment.name}”
仅仅编写类就足够了吗?Pseudo:“#{comment.name}”
@rabelloo有效!你可以把它作为一个答案,我会接受的,仅仅写这个类难道还不够吗?Pseudo:“#{comment.name}”
@rabelloo有效!你可以这样回答,我会接受的