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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:36:10+00:00 2026-05-27T13:36:10+00:00

I have an container element which is sort of a layout container for its

  • 0

I have an container element which is sort of a layout container for its children and based on some attributes I have to arrange children.

I need simple way to set outerHeight of an element, something like,

$(e).setOuterHeight(200);

jQuery’s outerHeight does not set the height at all, indeed its a readonly method.

$(e).height(200); // this clips my element

In above method, I loose borders of input of type text.

My element’s children are docked based on available space and some other criteria based on data that it holds, simple layouts like float,clear etc will not work because padding etc change dynamically based on sizes. I will finally end up using Table, even if I dont want to but have no choice, but anyway thanks for the help.

Now when element is sized to more then children then there is no problem, but sometimes container element may have lesser height then the children and that time, I need to increase the size.

function calculateSize(e){
   var s = { 
      width: $(e).innerWidth(), 
      height: 0 
   };
   var ae = new Enumerator(e.children);
   while(ae.next()){
      var child = ae.current();
      // I have tried all alternatives
      // for following lines
      // child.clientHeight || child.offsetHeight
      // $(child).outerHeight()
      // $(child).innerHeight()
      s.height += $(child).outerHeight(); 
   }
   if(s.height > $(e).height()){
      $(e).height(s.height);
   }
}

function layoutChildren(e){
      ....
      /// for every child c
      /// some steps before
      var heightForChildren = 
        calculatedWithPadMarginBorder(availableHeight,c);
      /// tried combinations
      $(c).height(heightForChildren);
      /// last statement fails for button
      /// as button's padding cuts itself
      /// removing padding in calculation
      /// cuts other input elements !!
      /// some steps after
      ....
}

I need some explanation of how to calculate runtime height/width including/excluding padding/margin/border etc and how to set it correctly so that I dont run into problems. I cant keep on trying all permutations combinations as I dont see a correct documentation even on jQuery website.

Fixed height calculations are fine, but this is kind of a dynamic element which resizes itself and arranges children in specific order.

Problem is there is no way to set outerHeight, when we set height/width of an element, the height/width is actually inner height/width without taking margin into consideration, while when we want to resize parent, we need outerHeight, but we cannot set back the outerHeight that easily.

My calculateSize and layoutChildren are two separate methods and two separate algorithms because parent will be resized to sum of all children’s height. And then height is simply divided by no. of children stacked one above other. My calculation is perfect, but in my layoutChildren method I have “outerHeight” and “outerWidth” of element and have no idea on how to set it correctly by using jQuery or any other way.

  • 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-27T13:36:10+00:00Added an answer on May 27, 2026 at 1:36 pm

    Ok, this is strange but this is the Answer.

    There are weird controls,

    • SELECT
    • BUTTON (INPUT[type=submit|reset|button])

    WebKit Browsers

    • Padding and Border are considered as part of OuterWidth for all controls
    • Padding and Border must be added to Width as OuterWidth for all controls
    • Padding and Border are considered as part of InnerWidth for “weird controls”
    • Padding and Border must be subtracted from Width before setting the Width for all “non weird controls”

    Non WebKit Browsers

    • Padding and Border are considered as part of OuterWidth for all non “weird controls”
    • Padding and Border must be added to Width as OuterWidth for all non “weird controls”
    • Padding and Border are considered as part of InnerWidth for all non “weird controls”
    • Padding and Border must be subtracted from Width before setting the Width for all “non weird controls”
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a container element which I need to resize as its contents change.
i have some element in my container and want to save all properties of
I have a container element in which I create on the fly/place() a form,
I want to be able to have a container element which contains the content
I have one std::list<> container and these threads: One writer thread which adds elements
I have a Canvas element, contained within a ScrollViewer, which I'm zooming using ScaleTransform.
I have an element which may contain very big amounts of data, but I
I have foreach function which calls specified function on every element which it contains.
I have a WSDL which contains 3 schemas inside it's types element. The schemas
I have a container element that you can drag objects around in. I want

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.