Page 1 of 1

Change news artcile style

Posted: Mon Oct 01, 2012 9:08 am
by douglas1438
Hi,

I'm listing 3 news article summaries on my home page in 3 CSS columns, the third column needs an added style 'nomargin' how can I detect the third article in my template to apply the additional style?

Have tried to use itemcount but this obviously isn't correct.

Code: Select all

{if $itemcount == 3}
<div class="newscol nomargin">
{else}
<div class="newscol">
{/if}
Thank you for any assistance.

Chris

Re: Change news artcile style

Posted: Mon Oct 01, 2012 5:35 pm
by Dr.CSS
Sometimes I use counter for something like this...

<div class="newscol nogo{counter}">

Gives nogo1, nogo2, etc. etc...

Re: Change news artcile style - Solved

Posted: Thu Oct 04, 2012 9:45 am
by douglas1438
Brilliant. That worked perfectly, thank you.

Re: Change news artcile style

Posted: Fri Oct 05, 2012 12:29 am
by mcDavid
you can also use the CSS3 selector :nth-child(3) or :last-child. Only donwside is that it won't work in older browsers (like IE8).

Re: Change news artcile style

Posted: Fri Oct 05, 2012 1:43 am
by Dr.CSS