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