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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:45:22+00:00 2026-05-20T18:45:22+00:00

The technique I have used to hide/unhide a div is as follows: $(# +

  • 0

The technique I have used to hide/unhide a div is as follows:

$("#" + sectionId).css("display", "");      // unhide
$("#" + sectionId).css("display", "none");  // hide

This works fine, except I need to make this hiding/unhiding not affect the dimensions on the rest of the page. That is, I do not want the act of hiding the content to shrink all the content around it. In other words, I would prefer to have the dimensions of everything on the page remain as it would be if the div were always visible. I’ve tried setting the div to zero height, but that doesn’t seem to have an effect.

Note: these divs actually reside within a table, hence cells are resizing automatically to fit content (which I do not want).

Update: Ok, half the problem is resolved but note that this is a table not a div that I am trying to hide/unhide. I need the table height to shrink down to zero but maintain its width.

  • 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-20T18:45:23+00:00Added an answer on May 20, 2026 at 6:45 pm

    Use visibility='hidden' and visibility='visible' instead:

    $("#" + sectionId).css("visibility", "visible");  // unhide
    $("#" + sectionId).css("visibility", "hidden");   // hide
    

    This will keep the object physically in the page but it will be “invisible”, as opposed to “removing” with display.

    More info.


    EDIT

    As for the new/editted question:

    Ok, half the problem is resolved but note that this is a table not a div that I am trying to hide/unhide. I need the table height to shrink down to zero but maintain its width.

    Set the table width to a fixed value and the hide the divs with content using display property:

    <table style="width: 500px;">
      <tr><td>
        <div id='div1'>Some content</div>
      </td></tr>
    </table>
    

    When you now hide the div1 using then code you’ve used in your question, the table width should stay the same width but shrink in height.

    EDIT2: A simple example.

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

Sidebar

Related Questions

I know it can be done in Java, as I have used this technique
I have used this snippet to prevent webkit from changing antialiasing when using CSS
Many times I have used an css technique that I learned by myself. When
I have another popups using this technique on the same page so it should
A technique I have used for a long time to do sorting in WPF
I've used the conditional comments technique for my IE6/7/8 CSS hacks, so that the
I have a few tabs on a page that have this markup <div id=holiday-details-nav>
What technique have these guys used to get a nice melow dropshadow on the
Example page I'm working on I used technique mentioned on this page : Basically
i have an extension in magento that when installed works fine but when i

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.