Share this Page URL

Chapter 21. Cascading Style Sheets and C... > Using Relative Positioning - Pg. 672

Cascading Style Sheets and CGI Programming document.getElementById(id).style.visibility = "hidden" document.getElementById(id).style.left = 0 document.getElementById(id) = 2000 } else { if((xData[loopIndex] > 0) && (yData[loopIndex] > 0)) { document.getElementById(id).style.visibility = "visible" document.getElementById(id).style.left = xData[loopIndex] document.getElementById(id) = yData[loopIndex] } } oldX = xData[0] oldY = yData[0] } } 672 Using Relative Positioning You also can position elements in a relative way, where they're positioned relative to the location they would have had in the normal flow of elements in the web browser. To position items in a relative way, you set the position style attribute to relative, and then you set properties such as left and top to specify the new relative position. What is the element being positioned relative to? It's positioned with respect to the place the browser would normally display the element if you didn't move it yourself. Here's an example. In this case, I'm moving some text up six pixels and other text down six pixels from the normal position at which the browser would place that text: Example . (Listing 21-10.html on the web site) <HTML> <HEAD>