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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:55:10+00:00 2026-05-31T16:55:10+00:00

Why I can’t get the min-height of an object when its parent is set

  • 0

Why I can’t get the min-height of an object when its parent is set to display: none, but I still can it the object’s height if the min-height is not in use?

For instance,

css,

li {
display:none;
}

.object {
display:block;
width:100px;
border:1px solid #000;
}

html,

<li><a href="#" class="object" style="height:200px;"><img class="element" /></a></li>
<li><a href="#" class="object" style="min-height:300px;"><img class="element" /></a></li>

jquery,

$(document).ready(function(){

    $('.object img').each(function(){
        alert($(this).parent().height());
    });

});

jsfiddle

How can I still get the min-height of the object even though its parent is set to display none?

  • 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-31T16:55:12+00:00Added an answer on May 31, 2026 at 4:55 pm

    When an element isn’t displayed, it has no height or width.

    You can extract the CSS attribute, though:

    alert($(this).parent().css('min-height'));
    

    http://jsfiddle.net/R5SDY/1/

    Note that this now returns a string with “px” at the end, instead of a number like height() does. You may need to parse it as an integer:

    alert( parseInt($(this).parent().css('min-height'),10) );
    

    Obviously if there’s no min-height set in CSS, this won’t work. Depending on what you want the number for, you may need to add some programmatic logic that extracts .css('height') if there’s no min-height returned.

    $(document).ready(function(){    
        $('.object img').each(function(){
            var h = parseInt($(this).parent().css('min-height'),10) 
                || parseInt($(this).parent().css('height'),10);
            alert(h);
        });
    });
    ​
    

    http://jsfiddle.net/R5SDY/2/

    Finally, remember that the values you’re getting from .css aren’t necessarily what the height will be when the element is finally displayed — they’re only what you want the height to be.

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

Sidebar

Related Questions

Can we set the alpha of drawable for its disable state through XML? For
Can you set the internal [[Class]] property of an ECMAScript object?
Can't get Youtube's homepage, or any other youtube.com prefixed URL to load in an
I am trying to understand how to use SyndicationItem to display feed which is
Can someone guide me on a possible solution? I don't want to use /bin/cp
Can somebody tell me how to get mod_rewrite to rename this: our-work-section.php?id=3&title=something to our-work-section/something/3
Can I use the Kinect Windows Live Messenger on a PC? I heard rumor
Can I set a maximum fps? Is there any way to limit fps in
can anyone tell me if it is possible to convert a dojo charting object
Can you have submenus with the top level set to checkable in WPF? 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.