Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8628301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:30:12+00:00 2026-06-12T08:30:12+00:00

I really need your help with this because I’ve no idea if this is

  • 0

I really need your help with this because I’ve no idea if this is even possible or correct.

This is my HTML

So, as you can see I have a <ul> with multiple <li>‘s in it. And what makes my whole thing complicated is the fact that there are <li class="wrapper year"> in it.

All those <li>‘s are floated side by side in 4 columns. I need a clear after every 4th element so the next row is horizonatally on the same level. However the <li class="wrapper year"> items are excluded from this behaviour because they should always clear:both.

First off, I know this might not be the perfect HTML Structure to have the “year” count also in a <li> element but based on the CMS in the backgound it might not be possible to do this in another way!

This is the CSS

ul.event-items li:not(.year):nth-of-type(4n+1) { clear: right; }
ul.event-items li:not(.year):nth-of-type(4n+2) { clear: left; }

Here is a live demo of the problem

This almost works fine, however I don’t get why the following is happening?!

So, as you can see the year 2012 as a count of 11 items, 2011 has 13 items, and 2010 has 12 items. So the vary because those items are based on a CMS.

The floating and clearing (after every 4th li) seems to work fine for 2012 and 2011 but when it comes to 2010 you can see the there is a clear after the 2nd element in this row. Why is that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T08:30:14+00:00Added an answer on June 12, 2026 at 8:30 am

    It’s happening because of your selector:

    ul.event-items li:not(.year):nth-of-type(4n+2) { clear: left; }
    

    You’ve an “orphan” in 2011. So the third li in 2010 is actually targeted by the rule above.
    What you can do is to add two “blank” lis at the end of 2011.

    Check the demo (the yellow ones are “blanks”). You can hide them if you want (same background color as the container etc.)

    Over time, i’m sure, this structure will give you a lot of trouble. If you can’t divide it in many uls, at least use some other classes and markers…

    Instead of targeting clearing lis with nth-of-type, add them a class (eg. clear-left, you actually don’t neet the clear:right;). The html will be a little “heavier”, but it’s surely safer.

    Check this updated demo for another way to do it without nth-of-type and clear:right;


    If you want to add the clear-left dynamically with jQuery, check this demo.

    Here’s the function i used:

    $('li.year').each(function(){
        $(this).nextAll('li').each(function(i){
            var li = $(this);
            /* break the loop when a new year is found */
            if(li.hasClass('year')) return false; 
            /* add clear-left to each 5th element */
            if( i > 0 && i % 4 == 0 ) li.addClass('clear-left');                      
        });
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I really need your help for this. I am relatively new to programming and
i really need you guys your help. I have to do animation on a
first of all, I'm really thankful for all your help. I need just one
I really need help with this last part of my program. I need to
I Really need help in this ... I'm building an application where I need
I really need help this time - Joomla 2.5 and latest K2. I'm using
I apologize for a lengthy question, but I really need your help. As a
I'm new to Java and really need your help. I am presently using a
I have another exercise I have to do that I really need help with.
Hello :) I realy need your help here. I dynamically generate list of items

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.