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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:04:48+00:00 2026-05-25T21:04:48+00:00

I am trying to solve a rectangle problem using jQuery. Basically, I have 3

  • 0

I am trying to solve a rectangle problem using jQuery. Basically, I have 3 square boxes which fix inside a larger box.

I know the larger box has a max-width of 500px. I do not know what the sizes of 1, 2 or 3 will be – but I know that their aspect ratio’s can change and that they must fit proportionally into the box.

How would I go about always ensuring that no matter what shape – the 3 rectangles are always proportionally sized inside the 500px box ?

  • 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-25T21:04:49+00:00Added an answer on May 25, 2026 at 9:04 pm

    After solving the system of equations, I believe the following is true.

    w  = Overall width (500)
    h  = Overall height
    w1 = Width of B1
    h1 = Height of B1
    w2 = Width of B2
    h2 = Height of B2
    w3 = Width of B3
    h3 = Height of B3
    a1 = Aspect ratio of B1 (width/height)
    a2 = Aspect ratio of B2 (width/height)
    a3 = Aspect ratio of B3 (width/height)
    
    w1 = (500/a2 + 500/a3) / (1/a1 + 1/a2 + 1/a3)
    

    500 px, a1, a2, and a3 are knowns. Solve for w1, then w2, and w3. Use a1,a2, and a3 to determine h1, h2, and h3.

    I believe your algorithm should be:

    1: Find w1
    w1 = (500/a2 + 500/a3) / (1/a1 + 1/a2 + 1/a3)
    
    2: Find w2 and w3
    w1+w2 = 500
    w1+w3 = 500
    
    3: Determine ideal h1, h2, and h3 via aspect ratio
    h1 = w1/a1
    h2 = w2/a2
    h3 = w3/a3
    
    4: Best-Fit h1, h2, and h3
    h = h1 = max(h2+h3, h1)
    h2 = h2 + ((h - (h2+h3))/2)
    h3 = h3 + ((h - (h2+h3))/2)
    

    Here are the steps I followed

    Eq1: w1/a1 = h1                              [aspect ratio]                
    Eq2: h1 = (h2 + h3)                          [see diagram]
    Eq3: h2 = w2/a2                              [aspect ratio]  
    Eq4: h3 = w3/a3                              [aspect ratio]  
    Eq5: w2 = 500 - w1                           [see diagram]
    Eq6: w3 = 500 - w1                           [see diagram]
    
    w1/a1 = h1                                   [Eq1]
    w1/a1 = (h2 + h3)                            [Eq2]
    w1/a1 = (w2/a2 + w3/a3)                      [Eq3, Eq4]
    w1/a1 = ((500 - w1)/a2 + (500 - w1)/a3)      [Eq5, Eq6]
    
    w1/a1 = 500/a2 - w1/a2 + 500/a3 - w1/a3
    w1/a1 + w1/a2 + w1/a3 = 500/a2 + 500/a3 
    w1 * (1/a1 + 1/a2 + 1/a3) = 500/a2 + 500/a3 
    w1 = (500/a2 + 500/a3) / (1/a1 + 1/a2 + 1/a3)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to solve a problem with templatetags. I have two templatetags: @register.inclusion_tag('directory/_alphabet.html') def alphabet_list(names):
In trying to solve the ajax back button problem I have found the Really
I'm trying to solve the 3n+1 problem and I have a for loop that
Trying to solve a very simple problem using mvvm-light, but after days of sifting
Trying to solve that problem, but no luck for hours... I have var screen1
Trying to solve a problem of preventing duplicate images to be uploaded. I have
Trying to solve this problem: I have the following set of divs that when
I'm trying to solve this problem where I have a unique array of values
trying to solve a puzzle which i found here: http://zcasper.blogspot.com/2005/10/google-phone-interview.html the goal is to
Trying to solve this problem . I would like to learn how the bootstrapper

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.