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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T10:28:08+00:00 2026-05-21T10:28:08+00:00

OK, first off, I am new at this so be gentle (please). I am

  • 0

OK, first off, I am new at this so be gentle (please). I am trying to layout multiple columns of divs. Each div contains multiple images stacked vertically. The images are all the same size. Here is what I’ve come up with using jQuery:

var $columns= $('<div />', {
    css: {
        align: 'center', position: 'absolute',
        height: 125, width: '100%', left: 0, top: 355, zIndex: 10
    },
    id: 'columns',
    text: 'Towers'
}).appendTo('#mainDiv');

for (var c = 0; c < 6; ++c) {
    var $c = $('<div />', {
        css: {
            marginLeft: 5, marginRight: 5,
            textAlign: 'center',
            top: 20, width: 20, zIndex: 20
        },
        id: 'c' + c
    });

    for (var i = 0; i < 8; ++i) {
        $c.append($('<img />', {
            css: {
                marginBottom: 0, zIndex: 30
            },
            id: 'c' + c + 'i' + i,
            src: 'image' + c + '.png'
        }));
    }

    $columns.append($c);
}

Each image is 17x11px. When I run this I get 6 columns with 8 images vertically stacked. But, the columns are all in a single column. I want them side-by-side. Is this just the totally wrong way to do it or am I at least close.

Extra credit: How do I make the images overlap each other by say 4px top to bottom?

  • 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-05-21T10:28:09+00:00Added an answer on May 21, 2026 at 10:28 am

    A <div> is a block element so it has display:block by default; this means that it is as wide as its parent unless you assign it a specific width. I think what you want to do is use inline-block with $c:

    var $c = $('<div />', {
        css: {
            display: 'inline-block',
            marginLeft: 5, marginRight: 5,
            textAlign: 'center',
            zIndex: 20
        },
        id: 'c' + c
    });
    

    Setting top won’t do anything for you as you haven’t specified a position. If the images are 17×11 then you should say so:

    $c.append($('<img />', {
        css: {
            marginBottom: 0, zIndex: 30
        },
        id: 'c' + c + 'i' + i,
        src: 'image' + c + '.png',
        width: 17,
        height: 11
    }));
    

    And if you want a bit of overlap, then set a negative top margin to push them up a bit and set display: block on the images.

    http://jsfiddle.net/ambiguous/949ey/

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

Sidebar

Related Questions

First off, I'm new to Java, so please be gentle. I have a JFrame
First off, I'm a real beginer at C# so please be gentle. I'm trying
First off I am fairly new to xcode. I am trying to add multiple
First off I am still new to objective-c and still trying to learn as
First off I am new to this site and it is a big help,
First off, a big thanks to the people behind the new boost::geometry library! This
this is my first post here. First off, some background, I'm new to C#
First off, fairly new to JS but getting better :-) This question is similar
First off, please accept my apologies if this question is basic, I mainly have
First off im very new to C# im trying to recreate a application i

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.