Not sure if this will work with your existing html structure and the way your classes are set up.
It looks like you can interrupt the :nth-child order by using the !important declaration. It appears to resume the count as you are wanting, unless I am unclear on that.
I was simply using div > div with !important as my override rule. Actually the :nth-child background color is still there, it’s just laying another layer on top. You can see that with the 20px side margins that were set on it.
After Ray.H’s mention of “reset” I thought of trying to lead off with a div.small-action { display: none; }
thinking it might remove those divs from the counting, but no joy.
So if a different “tiger striping” is wanted it would have to be done with a different DOM (not likely to happen in the Discourse Core code, but maybe if there was more demand for it) or by using JavaScript.
Hi @Mittineague,
You may have already solved this, but for the sake of working on my non existent JS skills I stayed with it until I found a solution.
The conditions were -
Don’t alter the html
Maintain tiger striping while skipping div.post-stream in the count
I wound up using :nth-of-type as I mentioned previously. The challenge for me while using my generic div structure was selecting an appropriate element to wrap around the skipped class. Couldn’t use a div and a “p” is not semantic.
Thought I had found the solution with the <element> element because of it’s transparent content model and ability to to define new custom DOM elements. Seemed to be just what I was looking for but it has been removed from the specs.
I went ahead and used <element> in my example anyway and it is working in all my browsers. Custom DOM elements are beyond my knowledge right now but it sounds like you could create your on element.
For what it’s worth, here’s what I came up with, you can see the new element with ff inspector.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Wrap element with new parent</title>
<style>
body {
width: 50%;
min-width: 300px;
margin: 2em auto;
}
div {
background: yellow;
}
div:nth-of-type(2n+1) {
background: lime;
}
element > .skip {
background: aqua;
margin: 0;
}
</style>
</head>
<body>
<div>1</div>
<div>2</div>
<div>3</div>
<div class="skip">4 .skip class</div>
<div>5</div>
<div>6</div>
<div>1</div>
<div>2</div>
<div>3</div>
<div class="skip">4 .skip class</div>
<div>5</div>
<div>6</div>
<div>1</div>
<div>2</div>
<div>3</div>
<div class="skip">4 .skip class</div>
<div>5</div>
<div>6</div>
<script>
function wrap(top, selector, bottom){
var target = document.querySelectorAll(selector);
for (var i = 0; i < target.length; i++){
var modified = top + target[i].outerHTML + bottom;
target[i].outerHTML = modified;
}
}
wrap("<element>", ".skip", "</element>");
</script>
</body>
</html>