I have the following sample:
- <html> <body>
-
<div id="mydiv" style="position: absolute;"> Hello </div>
-
<script>
-
alert(document.getElementById("mydiv").style.top);
-
</script>
-
</body> </html>
The resulting message box shows nothing. If I add "top: 10px" to the style (in the div tag), then it shows "10px". That means that I can't read the top/left/height/width properties without specifying them first. But I need to position another div based on the location/size of this div, which I don't want to specify explicitly (I'm using 'float' property and its height changes based on its content). Is there a way to do this?
I basically have two divs, "float: left" for both. The height of the one on the left is determined by its content, and I need to force the height of the one on the right to be exactly the same as the one on the left (I'm turning the scroll bars on for it).