I'm sure there is an easy solution, but I am missing it at the moment. Basicly I want to have three or four different divs that put their top location based on the bottom of the last div. So if someone resized the window and made it less wide then the top div would become taller and so the div below would need to move down some. I tried
var TextDiv = document.getElementById("text");
var LinkDiv = document.getElementById("stringlink");
LinkDiv.style.top = TextDiv.style.bottom;
// I also tried
LinkDiv.sytle.top = TextDiv.style.top + TextDiv.style.height;
window.onload = Resize();
window.onresize = Resize();
The only time it works is if I specifically give bottom or height a number value and not a % value, but I want all the divs to have % values so that they can adjust based on the size of the screen the user is using and not based on the size of the screen I tested it on.
Thanks again for your time.
12-18-2012, 04:50 PM
Use only CSS with a div without width (or 100%) and the three following with a class
12-18-2012, 05:40 PM
so in other words there is no way to circumvent the problem?
12-19-2012, 12:26 AM
I found the problem.
var x = Text.style.top;
returns a string with px appended to it. So to do arithmatic with two such variables you would end up with an appended string looking like
Trying to give that to a style value obviously breaks the code. I still haven't found out how to get the value of the height if it is based on a % width and the window resizes.
12-19-2012, 03:53 AM
Use offsetTop or offsetLeft (see for example this page) which are read only and give numbers.