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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:31:55+00:00 2026-06-11T09:31:55+00:00

I have a box that contains two boxes floating inside it. If the viewport

  • 0

I have a box that contains two boxes floating inside it. If the viewport is big, the boxes are next to each other. If the viewport is small, the boxes go one on top of the other (jsFiddle with fixes width and height just to illustrate the two scenarios I have: http://jsfiddle.net/5wpH9/)

I want to use jQuery to give the container box a height (not relevant, but every element inside my wrapper needs to have a fixed height, there can’t be elements floating freely without occupying vertical space). And I need to calculate the height of this container box based on IF the elements inside are floating above each other or not.

The little boxes inside have fixed height, so the result would be something like:

  • If elements are next to each other, make container 200px height
  • If elements are one on top of the other, make container 400px height

The only way I can think of is doing an offset() or position() calculation from the top of the second box to the top of the container (if it’s more than 10px, apply change). But I’m wondering if there is a better way to do it, something more straight.

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

    Checking .position() isn’t so bad:

    if($("#topElement").position().top - $("#bottomElement").position().top > 10) {
        $("#bottomElement").css("height", "400px");
    }
    

    Of course, you’ll want to change the IDs–but you get the idea.

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

Sidebar

Related Questions

I have a text box that contains lines of data similar to this: sheep
I have a list box control that contains enough items to list them with
I have a black box of code that contains many threads. There is no
I have two forms: one that takes user information (name, birthdate, etc): formA. And
I have a dialog box that contains a Scrollview, which contains a layout with
I have a table that has a column that contains links. Each cell in
I have a list box that contains a set of of PathItems. I have
I have a codeigniter form that contains two checkboxes: <input type=checkbox checked=checked id=box1 name=box1
I have a jQuery UI Dialog Box that contains a jQuery UI Autocomplete input
I'm databinding a listbox to an object that contains two array of strings. Each

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.