Skip to main content

Bug Tracker

Side navigation

#12499 closed bug (notabug)

Opened September 10, 2012 08:54AM UTC

Closed September 10, 2012 04:52PM UTC

.height() behaves oddly with margin on child elements

Reported by: admin@winterwind.co.uk Owned by: admin@winterwind.co.uk
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)

Attachments (0)
Change History (3)

Changed September 10, 2012 12:42PM UTC by mikesherov comment:1

owner: → admin@winterwind.co.uk
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?

Changed September 10, 2012 02:11PM UTC by admin@winterwind.co.uk comment:2

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.

Changed September 10, 2012 04:52PM UTC by mikesherov comment:3

resolution: → notabug
status: newclosed

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