position a div under another element
- by user555222
hi..
how can I position a div under another element without the rest of the layout is affected of the div element?
<div style="margin:20px; padding:10px">
here is a little <span id="test" style="font-weight:bold">test</span>
</div>
<script>
var elm = document.getElementById('test');
var div = elm.appendChild(document.createElement('div'));
with(div){
style.position = 'absolute';
style.left = elm.offsetLeft;
style.background = '#ffffff';
style.width = '100px';
style.height = '50px';
innerHTML = 'wooop';
}
</script>
this works in IE but not in FF.. FF ignores the style.left and position the element at 0px as if it was aligned to the left