Ernst wrote:
I have a script for a menu. However, this menu uses absolute
coordinates. This menu had to be placed on a website. This website is position
(centered) using a table. How can I determine/calculate where to fix
my menuregardless the browser, slidebar width, tool etc.
Why use JavaScript for layout? That what CSS was created for.
Programming your layout should always be a last resort.
You can *relatively* position an absolutely positioned element (place it
in a relationship with another element) by wrapping both in a relatively
positioned 'container' and adjusting the coordinates (left: / top:).
Absolutely positioned elements get their positioning context (x, y) from
their next outer containing element, if that element is itself
positioned, or the body/html element if none is positioned (depending on
doctype). Try this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>untitled</title>
<style type="text/css">
html, body {
height: 100%;
margin: 0;
background: buttonface;
}
div#container {
position: relative;
width: 722px;
height: 100%;
margin: 0 auto;
}
div#menu {
position: absolute;
left: 4px;
top: 2px;
width: 100px;
height: 200px;
border: 3px white groove;
background: crimson;
overflow: hidden;
}
div#menu hr {
height: 8px;width:90%;
}
table#content {
width: 720px;
height: 100%;
border-right: 1px black dashed;
border-left: 1px black dashed;
background: pink;
}
td {
width: 50%;
height: 102px;
}
</style>
<script type="text/javascript">
//<![CDATA[
//]]>
</script>
</head>
<body>
<div id="container">
<div id="menu">
<hr /><hr /><hr /><hr />
<hr /><hr /><hr /><hr />
<hr /><hr /><hr /><hr />
</div>
<table id="content">
<tbody>
<tr>
<td></td>
</tr><tr>
<td></td>
</tr>
<tbody>
</table>
</div>
</body>
</html>
Just a demo, your mileage may vary depending on that doctype.
http://www.brainjar.com/css/positioning/default.asp
*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!