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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:09:57+00:00 2026-06-14T03:09:57+00:00

I have a webpage which has three green boxes, each on their own line.

  • 0

I have a webpage which has three green boxes, each on their own line. Each green box also has an associated red box, which appears when you hover over the green box. All of the green boxes are contained within a black box, which is just wide enough to contain the widest green box.

JSFiddle

enter image description here

Question

How can I widen the shorter green boxes so they match the width of the widest green box? Here is an MSPaint rendition of what I would like to see:

enter image description here

Browsers I Am Testing With

At a minimum, I want to support Internet Explorer 7, 8, and 9. Firefox is optional. I am not interested in supporting any other browsers.

What I’ve Tried So Far

I have made a few attempts to attain this, but I can’t get it to work the way I want it to. (Feel free to skip these next parts if they’re boring.)

Attempt 1

I gave each green block the display:block style and removed the <br/>s between them.

JSFiddle

enter image description here

The green boxes are successfully resized! However, now each red box appears below its respective green box, rather than to the right. I don’t know if there’s any way to put the red box on the same line as a block element, so I abandoned this approach.

Attempt 2.0

I gave each green box a width of 100% and removed the <br/>s between them.

JSFiddle

enter image description here

(Ignore the gap between the green and red box. That’s there because there’s whitespace between the two spans, and is easy to repair.)

The green boxes are all the same size, but they are about 50px too wide and they extend past the end of the black box.

Additional browser-specific problems:

  • In IE7, the boxes all appear on one line.
  • In Firefox, the red boxes appear below their respective green box.

Attempt 2.1

From Attempt 2.0, I removed the green boxes’ padding. Padding is a very strong “it would be nice to have” feature, but I’ll ditch it if there’s literally no way to have it.

JSFiddle

enter image description here

The green boxes extend 1px past the end of the black box, which is annoying but not unacceptable. The boxes are still too wide. All of the browser-specific problems from 2.0 are still in effect.

Attempt 2.2

From Attempt 2.1, I re-added the <br/>s.

JSFiddle

enter image description here

The green boxes are the right width, give or take a pixel!

Browser-specific updates:

  • The boxes appear on their own lines in IE7, but they are not all the same width.
  • Firefox still shows the red boxes in the wrong position. In addition, there are big gaps between neighboring green boxes.

Attempt 2.3

From Attempt 2.2, I changed width to 99%.

JSFiddle

enter image description here

The green boxes are a little shorter than the black box, which is acceptable. As long as they are the same width.

Browser-specific updates:

  • In IE7, the boxes are still not the same width.
  • Firefox is working perfectly.

So I’ve got 75% browser compatibility at this point. However, It doesn’t seem like any amount of tweaking will get IE7 to work, so I gave up with this technique.

TL;DR

resizing boxes to fit a column is normally not too difficult. But normal methods fail when the boxes have fixed-pixel-width padding and absolutely positioned siblings that must appear to their right. I am seeking a method that will work under these particular circumstances.

  • 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-14T03:09:58+00:00Added an answer on June 14, 2026 at 3:09 am

    I verified that this demo works in IE7+ and modern browsers:

    http://jsfiddle.net/thirtydot/APVuq/4/

    CSS:

    .hoverBox {
        position: relative;
    }
    
    .visiblePart {
        display: block;
        border: 1px solid green;
        padding: 5px;
        white-space: nowrap;
    }
    
    .hiddenPart {
        display: none;
        border: 1px solid red;
        position: absolute;
        left: 100%;
        top: 0;
        white-space: nowrap;
    }
    
    .hoverBox:hover > .hiddenPart{
        display: block;
    }
    
    .enclosingBox {
        border: 1px solid black;
        display: inline-block;
        *display: inline;
        zoom: 1;
    }
    

    HTML:

    <div class="enclosingBox">
        <div class="hoverBox">
            <span class="visiblePart">
                Box 1
            </span>
            <span class="hiddenPart">
                Hidden part of Box 1
            </span>
        </div>
    
        <div class="hoverBox">
            <span class="visiblePart">
                Box 2, which is much wider than box 1
            </span>
            <span class="hiddenPart">
                Hidden part of Box 2
            </span>
        </div>
    
        <div class="hoverBox">
            <span class="visiblePart">
                Box 3, which <br/> is split into two lines.
            </span>
            <span class="hiddenPart">
                Hidden part of Box 3
            </span>
        </div>
    </div>​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a webpage which has three tabs, and depending on which tab is
Here's the situation I have a webpage which has one drop down called prefer.
I have a webpage which has a button placed inside a div. What i
I have one webpage (lets call it A.html). A.html has some javascript which switches
I have a web page which has three <div> elements: Right_bar contains several layouts
I have a webpage which has games on. I realize that there will be
I have a webpage which has an external javascript file attached to it .
I have a jQuery Mobile webpage which currently has a width=device-width but my form
I have an webpage which posts some data and then redirects to a page
I have a WebPage on which I have to detect and prevent usage of

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.