Get element dimensions including shadow

It looks like a suspicious straightforward question, but after searching the Google and StackOverflow, and have used the usual tricks ( getBoundingClientRect, clientWidth, offsetWidth), I have not found an answer.

Simply, is there a way to find the width / height of an element, including not only the border, padding, etc., but also the shadow?

See: jsfiddle for an example of how everything returns the width of an element without a shadow.

EDIT . Ideally, I would prefer not to examine the CSS attribute for the shadow and not analyze the dimensions, although this may be the only way.

+4
source share
1 answer

, . , -, box-shadow . . .

enter image description here

, x/y box-shadow / . , jsfiddle 10px x 10px y. 5px 2.5px , / :

104px () + 10px ( x) + 2,5 px () = 116,5

104px () + 10px ( y) + 2.5px () = 116.5px

0

Source: https://habr.com/ru/post/1624451/


All Articles