position a div under another element

Posted by user555222 on Stack Overflow See other posts from Stack Overflow or by user555222
Published on 2011-01-31T23:14:44Z Indexed on 2011/01/31 23:25 UTC
Read the original article Hit count: 169

Filed under:
|

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

© Stack Overflow or respective owner

Related posts about html

Related posts about css