0

I just want to add css on current div if prev div has some class.

My html

<div class="views-field views-field-field-1-image"></div>
<div class="views-field views-field-title"></div>

if div .views-field-title before has this div .views-field-field-1-image then add width on .views-field-title div.

4

3 回答 3

4

Use the adjacent sibling selector:

.views-field.views-field-field-1-image + .views-field.views-field-title {
    /* ... */
}
于 2013-03-19T18:22:45.500 回答
0
.views-field.views-field-field-1-image + .views-field.views-field-title {
    width: #px;
}

Documentation: http://www.w3.org/TR/CSS21/selector.html#adjacent-selectors

于 2013-03-19T18:25:00.023 回答
0

您可以为此使用相邻的兄弟选择器

.views-field-field-1-image + .views-field-title {
    YOUR CSS
}
于 2013-03-19T18:24:20.433 回答