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

  • Home
  • SEARCH
  • 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 7743333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:30:24+00:00 2026-06-01T09:30:24+00:00

I have a box of selectors all sharing the class. widgetContainer can hold 3

  • 0

I have a box of selectors all sharing the class. widgetContainer can hold 3 divs in a line before dropping into the next line. I’m using nth-child(3n+0) to take the margin off the right hand side of every 3rd div, allowing me to add more 10px more margin to the first 2 (this makes the divs fit exactly into the container).

But what I want to know is if there is a way to target the nth-child(3n+0) and remove the margin, but then target, as an example :not:nth-child(3n+0) to allow me to add the extra 10px margin on that? This allows me to keep my CSS the same and if the pseudo selector isn’t supported then it degrades well.

Let me show you my code:

HTML

<div class="widgetContainer">
    <div class="widgetBox">
        <dt>Title</dt>
        <dd>Lorem Ipsum..</dd>
    </div>
    <div class="widgetBox">
        <dt>Title</dt>
        <dd>Lorem Ipsum..</dd>
    </div>
    <div class="widgetBox">
        <dt>Title</dt>
        <dd>Lorem Ipsum..</dd>
    </div>
    <div class="widgetBox">
        <dt>Title</dt>
        <dd>Lorem Ipsum..</dd>
    </div>
    <div class="widgetBox">
        <dt>Title</dt>
        <dd>Lorem Ipsum..</dd>
    </div>
    <div class="widgetBox">
        <dt>Title</dt>
        <dd>Lorem Ipsum..</dd>
    </div>
</div>

CSS

.widgetBox {
    width: 300px;
    height: auto;
    float: left;
    margin: 30px 20px 10px 0;
    border: 3px solid #e4e4e4;
}
.widgetBox:nth-child(3n+0) {
    margin: 30px 0 10px 0;
}

On JSFiddle

What I can do with the CSS is make widgetBox have a margin of 30px 30px 10px 0, but this doesn’t work in browsers that do not support nth-child, it will force there to be 2 divs per row as the margin hasn’t been removed from the 3rd div.

Let me know if you need more clarification!

Note – I really would rather not use jQuery for this, but if it is a necessity, let me know and I’ll definitely consider using it!

  • 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-01T09:30:26+00:00Added an answer on June 1, 2026 at 9:30 am

    There is no not selector..just add two more styles:

    .widgetBox:nth-child(3n+1) {
        margin: 30px 30px 10px 0;
    }
    
    .widgetBox:nth-child(3n+2) {
        margin: 30px 30px 10px 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On line 6 below, I have $(ul.tabrow li).removeClass(active); //Remove any active class If I
I'm running into an issue where webrat can't see checkboxes. I have some code
Is there any way I can achieve this functionality, I have select all type
I have an html text box with some having class names as numbers <input
This is my requirement: I have a bunch of radio box selections (types of
I have a modal dialog box presented in Yahoo UI. The user selects a
I have a read only combo-box with 5 values in, when the user selects
I have text box to enter a phone number. I'm using AJAX MaskedEditExtender and
I have a box built via html borders. I want to connect the bottom
I have text box in which your adds values in comma separated values. Once

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.