Change news artcile style

For discussion and questions related to CMS Specific templates and stylesheets (CSS), and themes. or layout issues. This is not a place for generic "I don't know CSS issues"
Post Reply
douglas1438
Forum Members
Forum Members
Posts: 80
Joined: Thu Jul 21, 2011 10:29 am

Change news artcile style

Post 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
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12709
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: Change news artcile style

Post by Dr.CSS »

Sometimes I use counter for something like this...

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

Gives nogo1, nogo2, etc. etc...
douglas1438
Forum Members
Forum Members
Posts: 80
Joined: Thu Jul 21, 2011 10:29 am

Re: Change news artcile style - Solved

Post by douglas1438 »

Brilliant. That worked perfectly, thank you.
mcDavid
Power Poster
Power Poster
Posts: 377
Joined: Tue Mar 31, 2009 8:45 pm
Location: Delft, Netherlands

Re: Change news artcile style

Post 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).
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12709
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: Change news artcile style

Post by Dr.CSS »

Post Reply

Return to “Layout and Design (CSS & HTML)”