Link's style:
#carousel ul li {
display: inline-block;
border: solid 1px red;
margin: 50px 25px 50px 25px;
width: 350px;
height: 300px;
}
jQuery's code:
var height = $("#carousel ul li").outerHeight();
document.write(height);
And it says height of the element is 302px ! Why? It's maybe 302 with borders, but shouldn't outerHeight show 300 + 2 + 100 (both top and bottom margins are 50 px).
I'm confused.
Thanks.
By default outerHeight() does not include margins. Pass true to include margins in the calculation like this:
var height = $("#carousel ul li").outerHeight(true);
Nope. margin isn't counted. height, border and padding is.
if your li contains block elements with margin that is counted though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With