How to CSS select each first div without class after div with class?


Tags: html,css

Problem :

How to CSS select each first div without class following after div with certain class? Example:

<div class="someclass"></div>
<div class="someclass"></div>
<div class="someclass"></div>
<div></div> <!-- must be selected -->
<div></div>
<div></div>
<div class="someclass"></div>
<div class="someclass"></div>
<div class="someclass"></div>
<div></div> <!-- must be selected -->
<div></div>
<div class="someclass"></div>
<div class="someclass"></div>
<div class="someclass"></div>
<div class="someclass"></div>
<div></div> <!-- must be selected -->
<div class="someclass"></div>
<div class="someclass"></div>
<div></div> <!-- must be selected -->
<div></div>
<div></div>
<div></div>
<div class="someclass"></div>
<div class="someclass"></div>

Is it possible to select it without JS/JQuery?



Solution :

try https://jsfiddle.net/jr9wsr49/

CSS

.someclass + div:not(.someclass) {
  background:green
}

    CSS Howto..

    How to bottom align a title of variable length

    How can I programmatically position multiple backgrounds using Sass/Compass?

    How to make a pure css based dropdown menu?

    How to write two CSS files: with and without sourcemap

    How can I force a list item to display on one line with CSS?

    How to wait a while before adding elements in css? javascript?

    How to get parent DIV width and set child DIV width

    What is this HTML notation and how can I use it myself?

    How to remove the blue halo glow from jQuery Mobile input elements that receive focus

    How do i add a fading border to my nav bar CSS

    How to fake width animation with CSS transform?

    How to make CSS sourcemapping work in Chrome with Compass (SASS)

    How to make “transbox” full width

    W3.CSS how to get a standard header-[left-right]footer layout?

    How do I get this CSS to work in safari

    How to use the css height attribute for showing scroll bar in HTML table

    CSS Grid Layout Module Level 1 - How long does it usually take from candidate recommendation to final spec?

    how to move image vertically with css [closed]

    CSS: When I add a button to my container, my layout breaks, how to avoid this?

    How can I display links in 2 rows?

    How to read Base64 VLQ code?

    Website elements go haywire when the user zooms in or out. How do I keep them from moving?

    HTML/CSS: how to put text both right and left aligned in a paragraph

    How to change dropdownlist width to 100% using CSS

    How to make a CSS table with use of DIV UL LI

    How to manage text breaks in span using js, css or anything else

    CSS Flex Box: How to vertically align “flex items” to middle without losing flex item height?

    How to use media queries in css

    how to fix the difference in line thickness for a collapsable element

    How to use calc in CSS for mozilla firefox without position absolute