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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:56:36+00:00 2026-06-08T09:56:36+00:00

I have a page layout that needs to reduce from a 3 column layout

  • 0

I have a page layout that needs to reduce from a 3 column layout to a 2 column layout depending on the browser size. I am also using the jQuery masonry plugin to keep my grid of containers on the page arranged nicely. This all works fine on window resize.

The problem I am having is that if I load the page at the size smaller than 1100px it correctly calls the ‘col2.css’ stylesheet using jQuery, but the masonry plugin thinks it’s still a 3 column layout until you manually resize the browser so the grid is still at the col3 width and goes off the size of the container.

I’m guessing I need to somehow call the masonry function after jQuery has chosen the stylesheet, but I don’t know how to do this.

I have this in my head

<link href="<?=base_url()?>inc/css/col3.css" id="size-stylesheet" rel="stylesheet" type="text/css"  />

and the following javascript

    $(document).ready(function() {

        function adjustStyle(width) {
            width = parseInt(width);
            if (width < 1100) {
                $("#size-stylesheet").attr("href", "inc/css/col2.css");
            } else {
                $("#size-stylesheet").attr("href", "inc/css/col3.css"); 
            }
        }

        $(function() {
            adjustStyle($(this).width());
            $(window).resize(function() {
                adjustStyle($(this).width());
            });
        });

        //masonry       
        $(function(){
          $('#masonry').masonry({
            itemSelector : '.project',
            columnWidth : 365,
            isAnimated: true
          });
        });

    });

Any help would be greatly appreciated!

  • 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-08T09:56:39+00:00Added an answer on June 8, 2026 at 9:56 am

    First, based on the description. I think you are better seeking for the responsive design approach, this is a good article: http://www.alistapart.com/articles/responsive-web-design/. this my solve your problem, without switching Css manally.

    Second, a possible problem is that the masonry is applied when the col3.css is loaded, before switching to col2.css. Therefore, you have to load the col2.css as early as possible, this may be done by moving the related code out of document.ready function.

    function adjustStyle(width) {
            width = parseInt(width);
            if (width < 1100) {
                $("#size-stylesheet").attr("href", "inc/css/col2.css");
            } else {
                $("#size-stylesheet").attr("href", "inc/css/col3.css"); 
            }
        }
    //this runs when the page starts
    $(function() {
        adjustStyle($(this).width());
        $(window).resize(function() {
            adjustStyle($(this).width());
        });
    });
    //this runs when DOM is ready
    $(document).ready(function() {
        //masonry       
          $('#masonry').masonry({
            itemSelector : '.project',
            columnWidth : 365,
            isAnimated: true
          });
    });
    

    Third, if this does not solve the problem, you can always reload the masonry at some point to reorder the elements:

    $('#masonry').masonry('reload');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SharePointWebControls:UserField in a page layout that needs to be excluded from
I have a page that needs to accept .csv files with no predefined layout.
I have a page layout that I use in my SharePoint solution when I
I have an Administrator that needs a dynamic form generator with layout capabilities on
I have an MVC 3 Razor partial page that is dependent on jquery.validate.js and
I have a layout page within that layout I have used a partial view,
I have a two column layout page with a Validation Summary (VS) control above
I have a working zend mvc application that is using a layout, and this
I have a page layout involving a lot of position absolute and z-indexing, so
I have a simple page layout with two divs--one on top, and one on

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.