3

Is it possible to get the shape/outline of a DOM node in JavaScript? I would like to get some kind of representation of the shape or outline so that I can tell exactly which pixels the DOM node occupies. I can calculate the rectangle using width, height, and position, but this doesn't take into account the border-radius property, among others.

I know that I have access to all of the individual properties that will determine the rendered outline of a node (height, width, border-radius, etc), so I could, in JavaScript, reproduce the calculations the browser does. However, this would be pretty tedious and there would be a lot of edge cases.

4

1 に答える 1

0

また、ブラウザによってレンダリングが若干異なる場合があることを忘れないでください。これは、パディングとマージンにも関心がある場合です。

于 2013-05-24T13:04:31.283 に答える