Not sure if this is the right section, but I am currently running a wordpress loop for the search page. It displays the results in two different templates.
One of the templates I want to apply a clear both to the second one.
I think you fell for a common misunderstanding about the nth-child selector
#yourid:nth-child(2n) does NOT mean "select the nth child of the element with id=yourid"
It means: Select all elements with id=yourid (there can be only one!) and then filter those elements so that only those elements remain that are themselves the correct nth-child of their parents.
On top of that: Every id attribute on the same page can appear only once! You chose to use the same id="article-inspir" for several <article> elements which is illegal. So you should go for class="article-inspir" instead and change the selector to ".article-inspir"
Ok, regardless of the illegal ID use. This wouldn't work then ?
As I would be using #main :nth-child(2n) which would then select every second template within, which I don't want. I want it to select every second of a certain class (or in my case ID).
Ok, regardless of the illegal ID use. This wouldn't work then ?
As I would be using #main :nth-child(2n) which would then select every second template within, which I don't want. I want it to select every second of a certain class (or in my case ID).
i will say however, that you shouldn't actually need to use scripts for this.
simply use CSS to add clear:both to the same selector, or use :after content if you really need to inject a styled block.
in general with these sort of problems, just try out different permutations in the firebug or dev tools console until you hit the tags you want.
__________________ my site (updated 5/13) STATS (2013/5) HTML5:90.2% MOB:14% IE7:0.5% IE8:8.8% IE9:11.4% IE10:6.5%
i will say however, that you shouldn't actually need to use scripts for this.
simply use CSS to add clear:both to the same selector, or use :after content if you really need to inject a styled block.
in general with these sort of problems, just try out different permutations in the firebug or dev tools console until you hit the tags you want.
There is nothing in CSS that will work with this. Only nth term which isn't backwards compatible so that is why I'm using Jquery.
I've change to class's and it's not selecting. It's the only way to fix the problem. I've manually inputted the clear after every second and it fixes the problem, but I need to use javascript to append and no worky.
As you can see it's adding the XXX to the correct class.
But the clear doesn't.
I usually add the clear AFTER the div in the code, rather that TO the div. What would I need to do to get the jquery to add the code AFTER the div, rather than TO the div. If that makes sense.