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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:18:22+00:00 2026-06-17T00:18:22+00:00

I have tested masonry.js with multiple columns successfully but with my application I have

  • 0

I have tested masonry.js with multiple columns successfully but with my application I have the need to add masonry items dynamically using .ajax() JSON data. At the moment I have chosen to use .append() to layout the initial masonry .items – The issue is that all of the masonry items are being output in a single column. The container size changes didn’t help, even when increasing the amount of container width to more than enough, it will not style to 3 columns. Even when using the containerWidth function and using return containerWidth / 3

Here is the code:

jQuery(document).ready(function()
 {     
      $.ajax(
      {
          url: 'http://localhost/project/index.php/controller/function',
          dataType:'json',
          success: function(data) 
          { 
        // limit - used to limit the json data ouput, as the json data contains an array of 50 objects.
            var limit = 11;
            $.each(data.results, function(index,item)
            {
                if (index > limit) return false; 

                // A bunch of var assignments mainly for data_*
            $("#content").append('<div class="item ' + index + '"><a href="' 
                    + data_link + '">'
                    + data_title + '</a><p>'
                    + data_desc + '</p><img style="height:100; width:100;" src="'
                    + data_img + '"><p>'
                    + data_date + 'Source: '
                    + data_source + '</p></div>');
            }); 
          }
      });
        $('#content').masonry({
            itemSelector: '.item',
            isAnimated: !Modernizr.csstransitions,
            columnWidth: 350
         }).imagesLoaded(function() {
            $('#content').masonry('reload');
        });
 });

Here is the HTML in the view:

<header> // FYI I am using CodeIgniter & Twitter Bootstrap
</header>
<div class="container" style="padding-top:145px; width:1300px; margin-left:auto; margin-right:auto;">
<div id="content" class="container-mason clearfix">

    </div>
</div>
</div>

Here are the styles I from masonry.js – changed container to container-mason in styl.css to avoid any possible conflict with bootstrap

#container-mason {
   background: #FFF;
   padding: 5px;
   margin-bottom: 20px;
   border-radius: 5px;
   clear: both;
   -webkit-border-radius: 5px;
   -moz-border-radius: 5px;
   border-radius: 5px;
}
<style >

#content 
{
    margin: 0 auto;
    width: auto;
}

.item {
    height: 300px;
    width: 300px;
    border: 2px #0099cc solid;
     margin-bottom:10px;
    left: 10px;
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
     border-radius: 5px;
    -webkit-transition: left .4s ease-in-out, top .4s ease-in-out .4s;
    -moz-transition: left .4s ease-in-out, top .4s ease-in-out .4s;
    -ms-transition: left .4s ease-in-out, top .4s ease-in-out .4s;
    -o-transition: left .4s ease-in-out, top .4s ease-in-out .4s;
    transition: left .4s ease-in-out, top .4s ease-in-out .4s;
}    
</style>

Thanks for the help!!

UPDATE

Here is the JsFiddle http://jsfiddle.net/8CjT6/5/

  • 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-17T00:18:23+00:00Added an answer on June 17, 2026 at 12:18 am

    I think you have missed the style float: left for the items class.

    Check this fiddle.

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

Sidebar

Related Questions

I have tested the scrollTo() plugin, but I need a way to stop the
I have tested a web application I have built using MVC 2 on local
I have tested the below script on a demo page which is not using
I have tested my application on various mobile phones. My applications main functionality is
i have made my custom Static Library (.a) successfully. i have tested it in
I have tested this on my development computer, but now I have uploaded everything
i have tested following code which might print 0 and 2 but it print
I have tested PHP's IMAP lib. to fetch emails from a GMAIL account, but
I have an working application which i have tested in my ipod touch. Everything
I have made a model using Sketchup, and have tested rendering it using Blender

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.