Reputation: 9742
Inline-block seems to make elements not match the ":visible" selector?
$('body').append($('<p>').css('display', 'inline-block'))
var p = $('p');
p.is(':visible');
==> false
p.css('display', 'block');
p.is(':visible');
==> true
Upvotes: 0
Views: 227
Reputation: 9388
From jQuery (http://api.jquery.com/visible-selector/) :
Elements are considered visible if they consume space in the document. Visible elements have a width or height that is greater than zero.
An empty inline-block will have a height and width of 0 (the width is based on the contained elements)
An empty block element will have a width of the parent element
More info can be found at w3.org on how width is determined for inline and block level elements.
Edit: As Fabrício Matté points out, this assumes the elements are both empty and appended to the DOM. Detached, even the block element has no parent to calculate layout and will return false.
Upvotes: 2