3

Some times I need to know whether a element is visible. Looking in forums I got that a easy way to know this is getting the offsetParent (not null). But, sometimes, the parent exists but height and width is zero, resulting in a no visible element. Now I realize that there are situations in which the element is visible but client{Width,Height} properties are zero!!!

In this question (clientWidth and clientHeight report zero while getBoundingClientRect is correct), a new feature overcame to me: in order to these properties to work properly, the element need to be associated to a CSS layout box!

1.If the element has no associated CSS layout box or if the CSS layout box is inline, return zero.

How to know if a element is associated to CSS layout box?

Daniel Bandeira
  • 360
  • 1
  • 2
  • 12
  • 1
    I'm not sure what you're trying to get to here, but I doubt if knowing whether an element has a layout box will help you. For example, an element with a computed value for display of `contents` will have no associated layout box, but its contents will be visible nonetheless. – Alohci Jul 10 '19 at 01:34
  • I want to know safely whether a element is visible. Only that. Knowing it, I would create a more roubust function (or something else) capable evalute the real visbiliry condition of a element. Anyway, thank you for replying. Your comment was significant to this problem. – Daniel Bandeira Aug 07 '19 at 12:05

0 Answers0