wtorek, marca 08, 2005

Ciekawe użycie div do pozycjonowania elementów na stronie

********** THE TIP **********

Use nested div elements to standardize browser behavior when
seeking information, such as padding size, from JavaScript

If your JavaScript needs to know the exact position and size of
elements on the page (e.g., to create and control DHTML effects),
you may have some problems with the many variations between
browsers. For instance, to dynamically calculate the size of
paddings and borders (assuming these might change in your
application), you'll need different approaches for different browsers.

One shortcut that sometimes works to simplify these sorts of
calculations is to add extra nested
tags. For instance, say
your element has padding. You can nest another
inside that
and place your content there. That way, you can use offsetLeft
and offsetTop to find the position of the inner element in
relation to the outer one instead of using the browser-specific
approaches for returning the padding value.

Brak komentarzy: