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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:52:44+00:00 2026-05-28T13:52:44+00:00

I HAVE UPDATED WITH FIDDLES, SEE BOTTOM I am developing a wordpress theme to

  • 0

I HAVE UPDATED WITH FIDDLES, SEE BOTTOM

I am developing a wordpress theme to work on iphone and ipads and other webkit devices.

I am using media queries to change the width of divs depending on the size and orientation of the device.

These divs however float left, to fill the device screen.

My problem is that the floated div’s height are variable. And the div’s which are higher than some, are causing gap issues on the floated elements.

I need possible advice on a fix so there are never any gaps, and elements always float, even if there is a higher div in its path.

Is there a possible way of equalizing the div heights to the highest div, the only problem with this is that it need to work with orientation changes on iPad. On iPhone it’s not so bad because there is only one column. But on iPad, portrait has 2 columns and landscape has 3 columns.

Please see diagram below explaining my issue.

Diagram

CURRENT CSS

/* GLOBAL STYLE ( which iPhone uses first - 1 column ) ----------- */

.module {
    display: block;
    overflow: hidden;
    width: 100%;
    float: left;
}

/* IPADS (PORTRAIT - 2 column ) ----------- */
@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait) {

    .module {
        width: 50%;
    }

}

/* IPADS (LANDSCAPE - 3 Column ) ----------- */
@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape) {

    .module {
        width: 33.33%;
    }

}

BASIC MARKUP

<div>

    <div class="module"></div>
    <div class="module"></div>
    <div class="module"></div>
    <div class="module"></div>
    <div class="module"></div>
    <div class="module"></div>
    <div class="module"></div>
    <div class="module"></div>
    <div class="module"></div>
    <div class="module"></div>

</div>


UPDATE – I HAVE CREATED PURE CSS FIDDLES TO SIMULATE MY PROBLEM

The fiddle below simulates SMARTPHONES (PORTRAIT AND LANDSCAPE) – ONE COLUMN

See style .module – width: 100% which simulates the appearance of this @media query

@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px)

http://jsfiddle.net/motocomdigital/kdgnP/1/

The fiddle below simulates IPADS (PORTRAIT) – TWO COLUMN

See style .module – width: 50% which simulates the appearance of this @media query

@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait) {

http://jsfiddle.net/motocomdigital/kdgnP/2/

The fiddle below simulates IPADS (LANDSCAPE) – THREE COLUMN

See style .module – width: 33.33% which simulates the appearance of this @media query

@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape) {

http://jsfiddle.net/motocomdigital/kdgnP/3/

  • 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-28T13:52:45+00:00Added an answer on May 28, 2026 at 1:52 pm

    Like I said in a comment, you need to calculate this in javascript and use absolute positioning. Here is an example:

    http://jsfiddle.net/rJxtm/4/

    //Generate random height for each module, normally this doesn't need to be done because
    //they have various amounts of contents in a real app.
    $(".module").each(function(i) {
        var height = (150 + (Math.random() * 100 | 0));
        this.style.height = height + "px";
    });
    
    
    $(window).bind("orientationchange resize", function(e) {
        var modules = $(".module"),
            columnWidth = modules[0].offsetWidth,
            margin = 10,
            parentWidth = $(".modules").width(),
            fits = Math.floor(parentWidth / (columnWidth + margin * 2)),
            columnHeights = {},
            i;
    
        for (i = 0; i < fits; ++i) {
            columnHeights[i] = 0;
        }
    
        function getTop(i) {
            var nColumn = i % fits;
            return columnHeights[nColumn];
        }
    
        modules.each(function(i) {
            var height = this.offsetHeight, //Now I am just retrieving the height
                nColumn = i % fits;
    
            this.style.left = ((columnWidth + margin) * nColumn) + "px";
            this.style.top = getTop(i) + "px";
            columnHeights[nColumn] += (height + margin);
        });
    
    }).trigger("resize");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have updated to latest Django version 1.0.2 after uninstalling my old Django version.But
I have updated many records already, but when it came to a word that
I have updated my libraries, and now e-mails are sent without subject. I don't
Okay I have updated my code quite a bit. I am getting a new
Okay I have updated my code a little, but I am still not exactly
I have recently updated my model, added a BooleanField to it however when I
I have just updated os x to 10.6.3 and no Eclipse won't start the
I have recently updated the Cucumber gems ('cucumber' and 'cucumber-rails') on my machine and
I have just updated to Snow Leopard and one of my important Flash files
The table doesn't have a last updated field and I need to know when

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.