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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:12:32+00:00 2026-05-23T08:12:32+00:00

UPDATE 1: I’ve found that when removing width:100% from the div, I get the

  • 0

UPDATE 1:

I’ve found that when removing width:100% from the div, I get the results I want interms of it having 0 height if it contains no content. However, I need the div to have a width of 100%, which for some reason is forcing it to have a height without content.

Here is a jsfiddle of the problem. You will only see the problem if you go to the following link with IE7, maybe on IE6 and below.

http://jsfiddle.net/RQeeg/2/

ORIGINAL QUESTION:

I have an empty div which has a height for some reason.

On Chrome, the div does not appear at all unless it contains content. IE7 on the other hand shows the div even if it has no content.

So basically, I want it to have a height of 0px if it is empty, and automatically adjust it’s height if it has content. Which is exactly how it behaves if it does not have a width of 100%.

  • 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-23T08:12:33+00:00Added an answer on May 23, 2026 at 8:12 am

    Update after the revelation that you’re using position: fixed:

    To support IE7 here, you must use two divs. I’m reasonably sure there’s no way round this (unless you’d prefer to stick with one div and use a JavaScript fix).

    See:
    Without content: http://jsfiddle.net/r3P8D/2/
    With content: http://jsfiddle.net/r3P8D/3/

    The reason that this bug happens is because once you add certain properties such as width: <not auto> or position: fixed, you trigger hasLayout on the element. As soon as you trigger hasLayout, this bug happens.

    Because you require position: fixed (..which doesn’t even work in IE6, but I digress), there is no way to avoid hasLayout, and hence no way to avoid this bug.

    So, I’ve given you the best workaround I can think of.


    Old answer:

    However, I need the div to have a
    width of 100%

    Simply don’t use width: 100%.

    The div will then have the default width value, which is auto, so it will take “the full available width”. width: auto is not the same as width: 100%, but for the purposes of this question, it looks the same visually.

    Check this in Chrome and IE6/7 (without content): http://jsfiddle.net/r3P8D/
    Check this in Chrome and IE6/7 (with content): http://jsfiddle.net/r3P8D/1/

    From my understanding of your question, this is exactly what you’re asking for.

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

Sidebar

Related Questions

Update I want to have an expression (XPath, or Regex Expression, similar) that can
Update : I found the solution by removing v.setFocusable(true); v.setClickable(true); in the code and
Update: Now that it's 2016 I'd use PowerShell for this unless there's a really
UPDATE - A comprehensive comparison, updated as of February 2015, can be found here:
UPDATE: I've completely changed the question because in reality, I'm having a really hard
UPDATE: I now have a solution I'm much happier with that, whilst not solving
UPDATE: It was suggested in the comments that I create a wiki for this.
UPDATE TABLE1 set TABLE1.col1 = TABLE2.col1 FROM TABLE2 INNER JOIN TABLE3 ON COL2 =
Update 14th May It's the mix of text sizes that breaks it, if I
UPDATE users u JOIN (select count(*) as job_count, user_id from job_responses where date_created >

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.