Bug Tracker

Opened 7 years ago

Closed 7 years ago

#12499 closed bug (notabug)

.height() behaves oddly with margin on child elements

Reported by: admin@… Owned by: admin@…
Priority: undecided Milestone: None
Component: unfiled Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:

Description

I was trying to make a "one size fits all" method for dynamic height resizing (by hiding the element I was resizing and then comparing parent height to parent's parent height) when I noticed that .height() (and .outerHeight(true)) were failing to return the correct value.

For the sake of simplicity, we'll call the elements a > b > c > d, e (with d & e being siblings)

a is a fixed height element (height: 640px) (no padding/margin) b is a fixed height element (positioned absolutely to top,right,bottom,left: 20px, no padding/margin - so is height: 600px by inference) c is a variable height element (no padding/margin) d is a fixed height element (height: 10px) (no padding, has 20px total vertical margin) e is a fixed height element (element to be resized) (no padding/margin)

If I hide e, then do b.height() - c.height() then it should return 570px as the height of d should be stretching the height of c to 30px, however what is actually being returned is 590px.

The same happens if I call b.height() - c.outerHeight(true)

Change History (3)

comment:1 Changed 7 years ago by mikesherov

Owner: set to admin@…
Status: newpending

Thanks for contributing! This is a nice detailed description of a problem. Can you please recreate it using JSBin.com or jsfiddle.net so I can clearly see the problem in action?

comment:2 Changed 7 years ago by admin@…

Status: pendingnew

No able to replicate in JS fiddle, so going to chalk it up as not a jQuery bug :)

Further testing on my site shows it's only happening inside a fancybox 2 window, so there's probably some dodgy CSS floating around somewhere.

My apologies for wasting your time.

comment:3 Changed 7 years ago by mikesherov

Resolution: notabug
Status: newclosed

No problem! Thanks for contributing and feel free to submit another bug report if you can identify an issue.

Note: See TracTickets for help on using tickets.