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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:43:11+00:00 2026-05-24T06:43:11+00:00

My question is regarding CSS with Jquery which will create three columns that run

  • 0

My question is regarding CSS with Jquery which will create three columns that run from left to right, top to bottom. Right now the data is all being placed into one column.

Here is the jquery:

function smartColumns() { 
$("ul.column").css({ 'width' : "100%"});
var colWrap = $("ul.column").width();
var colNum = Math.floor(colWrap / 200);
var colFixed = Math.floor(colWrap / colNum);
$("ul.column").css({ 'width' : colWrap});
$("ul.column li").css({ 'width' : colFixed});
}   
smartColumns();
$(window).resize(function () {
smartColumns();
});

Here is the javascript function which creates the data, and outputs the data in a div called sidbar which is listed below the function:

 function createSidebarEntry(marker, name, address, city, state, zipcode, telephone, images, url) {
  var div = document.createElement('div');
  var html = "<ul class='column'><li><div class='block'><a href='http://" + url + "'>" + name + "</a><br/>" + address + "<br/>" + city + ", " + state + " " + zipcode + "<br/>" + (formatPhone(telephone)) + "</div></li></ul>";
  div.innerHTML = html;
  div.style.marginBottom = '5px'; 
  return div;
  }

<html>
<div id="sidebar"></div>
</html>

Here is the CSS that the DIV utilizes:

#sidebar
{
width:665px;
font-size:10pt;
font-family:Arial;
color:#656668;
}
ul.column{
width: 100%;
padding: 0;
margin: 10px 0;
list-style: none;
}
ul.column li {
float: left;
width: 200px; /*Set default width*/
padding: 0;
margin: 5px 0;
display: inline;
}
.block {
height: 60px;
font-size: 1em;
margin-right: 10px; /*Creates the 10px gap between each column*/
padding: 0px;
background: #FFFFFF;
}
.block h2 {
font-size: 1.8em;
}
.block img {
    /*Flexible image size with border*/
width: 89%;  /*Took 1% off of the width to prevent IE6 bug*/
padding: 5%;
background:#fff;
margin: 0 auto;
display: block;
-ms-interpolation-mode: bicubic; /*prevents image pixelation for IE 6/7 */
}
#sidebar a:link 
{
color:#192A96;
font-weight:bold;
font-size:10pt;
font-family:Tahoma;
text-decoration: underline;
}
#sidebar a:visited 
{
color:#192A96;
font-weight:bold;
font-size:10pt;
font-family:Tahoma;
text-decoration: underline;
}
#sidebar a:hover
{
color:#192A96;
font-weight:bold;
font-size:10pt;
font-family:Tahoma;
text-decoration: underline;
}
#sidebar a:active
{
color:#192A96;
font-weight:bold;
font-size:10pt;
font-family:Tahoma;
text-decoration: underline;
}

The goal of this is to create 3 columns, within 665px, and have the data populate the paragraphs from left to right, then top to bottom.
However currently what is happening is the paragraphs are all placed in one column on the left side and the data is populated top to bottom in one column
thanks

  • 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-24T06:43:13+00:00Added an answer on May 24, 2026 at 6:43 am

    I think your styles are right, but only one li is being created in your html variable, so you’re only getting one column.

    If you break up the fields into three lis, it works as far as I understand. You can see an example at:

    http://jsfiddle.net/eZPTj/1/

    Is this what you’re after?

    EDIT:

    I think I get it now. Is this what you’re after?
    http://jsfiddle.net/eZPTj/7/

    I believe the main thing I changed was just the settings on the ul – setting the float on the ul:

    ul.column {
        width: 100%;
        padding: 0;
        margin: 10px 0;
        list-style: none;
        float: left;
    }
    

    Then setting the jQuery-generated CSS rules to be 200px instead of 100%, since 100% would take up the whole sidebar div. I changed it to $("ul.column").css({ 'width' : "200px"});

    I also changed the innerHTML method to $('div#sidebar').append(html);, since that wasn’t working for me, at least in my testing, where I just called the function six times so you could see the columns displaying. append adds the html to the previous entry, instead of overwriting it. You may be calling the function differently though.

    Just for my own test, I took out the formatPhone() function since I assume that’s defined somewhere else in your code, but throws an error because I don’t have access to it :). You can keep that in if it’s needed.

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

Sidebar

Related Questions

It's actually two part question regarding my simple page (that will be replaced some
First question from a long time user. I'm writing a Perl script that will
Quick question regarding CSS and the browser. I tried searching SO and found some
simple question regarding property value inheritance in UserControls. If i create a UserControl, it
I have a question regarding the two additional columns (timeCreated, timeLastUpdated) for each record
I have a question regarding an update function I created... CREATE OR REPLACE FUNCTION
I have a question regarding image alignment with CSS. For example I have created
I had that question in mind for a long time. Theoretically, jQuery core function
Hey all, quick question regarding CSS. On my website , I'd like it if
I have a very, i think basic, question regarding CSS with floating div objects.

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.