如果prev div有一些类,我只想在当前div上添加css。
我的HTML
<div class="views-field views-field-field-1-image"></div>
<div class="views-field views-field-title"></div>
如果div .views-field-title
之前有此div .views-field-field-1-image
,则在.views-field-title
div上添加宽度。
答案 0 :(得分:4)
.views-field.views-field-field-1-image + .views-field.views-field-title {
/* ... */
}
答案 1 :(得分:0)
您可以使用adjacent sibling selector:
.views-field-field-1-image + .views-field-title {
YOUR CSS
}
答案 2 :(得分:0)
.views-field.views-field-field-1-image + .views-field.views-field-title {
width: #px;
}
文档:http://www.w3.org/TR/CSS21/selector.html#adjacent-selectors