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 649891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:59:36+00:00 2026-05-13T21:59:36+00:00

This problem is similar to when creating alternate colour table-rows, only we are dealing

  • 0

This problem is similar to when creating alternate colour table-rows, only we are dealing with divs and margins instead of table rows and their colours.

The following code creates as many layers as there are genres returned from a query (if three genres are found, three layers are created); and within each layer created, the code creates as many layers as there are titles within that genre (for example, if there are five titles per genre, there will be three “genreName” layers, and inside each one there will be five “titleName” layers).

<cfoutput query="MyQuery" group="genreName">
    <div class="Genres">
        #MyQuery.GenreName#
        <cfoutput>
            <div class="Titles">
            #MyQuery.TitleName#
            <div>
        </cfoutput>
    </div>
</cfoutput>

This also means that all layers in each class are clones. If I have a columns layout where I do not want to assign a left/right margin to the first/last columns, this format breaks.

Is there a programmatic way to assign margins based on the layer number (record number, essentially) where I can apply conditional formatting (in this case, a left and right margin for the middle columns, and no left/right margins for first/last columns)?

Many thanks,

  • 1 1 Answer
  • 2 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-05-13T21:59:36+00:00Added an answer on May 13, 2026 at 9:59 pm

    If what you actually want to do is having a fixed margin between elements, but none before the first nor after the last, you can use the first-child pseudo-class to overrule the general case:

    has_margin { margin-left: 20px; }
    column_container:first-child { margin-left: 0px; }
    
    ...
    <div class="column_container">
         <div class="has_margin">...</div>
         <div class="has_margin">...</div>
         <div class="has_margin">...</div>
         <div class="has_margin">...</div>
         <div class="has_margin">...</div>
    </div>
    

    CSS3 defines a ‘structural pseudo selector’ that allows you to select every an+b’th child of an element. Setting a to the number of class clones allows you to define that many rules for each layer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My example is similar to this - The only problem is I cannot rewrite
I read similar questions to this problem but I couldn't find out why it
I noticed some similar questions about this problem when I typed the title, but
I have a cross-tab report which similar to this Problem is when there are
I referred this on SO as the problem was similar to mine. In my
An issue I discover today is similar to this unanswered problem ; though not
I notice this thread: Fastish Python/Jython IPC , and I have a similar problem,
My problem is extremely similar to the one described in this SO question ,
This is similar to an earlier problem I was having which you guys solved
I'm creating a database with Access. This is just a test database, similar to

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.