Can I easily set the offsetWidth element?

Note. I know that offsetWidth only reads

I am trying to create a popup "div" overlay a trwith the same width.

However, I cannot say how to set div widthit offsetWidthto be the same as it is tr.

The calculation will look something like this:

div.width = tr.offsetWidth - div.paddingWidth - div.marginWidth

but, of course, the best way (since I can only think about getting indentation and field offsets in groups of two ...)

In particular, I would like to receive a response to YUI 2. If possible,

+3
source share
2 answers

If you reset the marker divand paddings, then the following works:

YAHOO.util.Dom.setStyle(div, 'width', tr.offsetWidth + 'px');

, div tr, tr.clientWidth.

/paddings / div .

, , , clientWidth offsetWidth measure, CSS width - , ( . W3C).

.. ,

+2

, , , , , , - div , div offsetWidth. , , .

div.style.width = '20px'
diff = div.offsetWidth - 20;
div.style.width = tr.offsetWidth - diff;

, , .

+1

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


All Articles