Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,253
Total Threads: 80,789
Total Posts: 566,436
There are 52 users currently browsing (tf).
  Our Partners:
  TalkFreelance     Design and Development     HTML/XHTML/DHTML/CSS :

nth-of-type problem.

Thread title: nth-of-type problem.
    Thread tools Search this thread Display Modes  
03-19-2012, 01:52 AM
Dan is offline Dan
Dan's Avatar
Status: Request a custom title
Join date: Feb 2005
Posts: 3,164
iTrader: 15 / 86%

Dan is an unknown quantity at this point

  Old  nth-of-type problem.

I'm wanting to style every other 3 items. Is there a better solution than my hacked together code? It feels dirty.

li:nth-of-type(6n+2), li:nth-of-type(6n+1), li:nth-of-type(6n+3)

03-24-2012, 12:43 AM
Choco is offline Choco
Status: Member
Join date: Jul 2007
Location: USA
Posts: 240
iTrader: 2 / 100%

Choco is on a distinguished road

Send a message via MSN to Choco


I'm pretty sure that's the only way to do it. There's no way to select groups of elements (in your case, groups of 3) and then alternate with something like an nth-of-type(odd) selector.

03-24-2012, 06:46 PM
derek lapp is offline derek lapp
Status: design rockstar
Join date: Jan 2005
Location: guelph, ontario
Posts: 2,246
iTrader: 0 / 0%

derek lapp is on a distinguished road


i think you'll need to use either javascript or php with a $counter variable and the % operator in something like php if you have to accommodate lame, older browsers.

04-07-2012, 12:20 AM
shakemelikeapig is offline shakemelikeapig
Status: On Vacation
Join date: Dec 2009
Posts: 70
iTrader: 0 / 0%

shakemelikeapig is on a distinguished road


I'm not exactly sure what you want to do here, but there are many different ways to do this. Are you using php or is this in a template of another script?

Reply With Quote

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed