Afficher un message
Vieux 18/03/2008, 01h36   #3
Summercool
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: how to display the margin of a <p> element

On Mar 17, 4:18 pm, Jeremy <jer...@pinacol.com> wrote:

> Seehttp://www.quirksmode.org/dom/getstyles.htmlfor a useful
> cross-browserish method of getting the current style of an element.


thanks for the tip.
so

function getStyle(el,styleProp)
{
var x = document.getElementById(el);
if (x.currentStyle)
var y = x.currentStyle[styleProp];
else if (window.getComputedStyle)
var y =
document.defaultView.getComputedStyle(x,null).getP ropertyValue(styleProp);
return y;
}

alert(getStyle("ha", "marginTop"))

will show "auto" in IE and an empty string in Firefox. If I add a
style for <p> as margin: 10px, then IE will show 10px and Firefox will
not show anything.

  Réponse avec citation
 
Page generated in 0,05249 seconds with 9 queries