Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Style left

Status
Not open for further replies.

dexeloper

Programmer
Joined
Oct 26, 2004
Messages
162
Location
GB
Can someone tell me why 'abc' does not move to the right 500px when you take the cursor over 'shift'?

<html>
<head>
<script language="javascript">
function doEl() {
document.getElementById("opt1").style.left=500;
document.getElementById("opt1").style.visibility="visible";
}
</script>
<style type="text/css">
.opthid {visibility:hidden;}
</style>
</head>
<body>
<div id="opt1" class="opthid">abc</div>
<div onmouseover="doEl()">shift</div>
</body>
</html>
 
try

Code:
function doEl() {
document.getElementById("opt1").style.left=[!]"500px"[/!];
document.getElementById("opt1").style.visibility="visible";
}

-jeff
try { succeed(); } catch(E) { tryAgain(); } finally { rtfm(); }
i like your sleeves...they're real big
 
As well as that change, your CSS should be:

Code:
<style type="text/css">
.opthid {
	visibility:hidden;
}
#opt1 {
	position: relative;
}
</style>

You cannot arbitrarily move non-positioned (i.e. static) elements - that's why they're called static!

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Dan

You're a star.

Many thanks,
dexeloper
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top