Is there a way to dynamically set the top CSS when an element is over the top or bottom of a page?
First, hover over the first cat image. It's working fine.
http://image.ohozaa.com/i/480/7YpWei.jpg
When I scroll the page to the bottom and hover over the first cat image again,
http://image.ohozaa.com/i/5b5/l2l3dj.jpg
The big cat image is now over the top of the page.
And when I scroll the page to the top and hover over the 3rd cat image again,
http://image.ohozaa.com/i/5db/ezZE1b.jpg
The big cat image is now over the bottom of the page.
How can I change the top CSS of the mouse-over effect element so that it does not cover the top or bottom of the page?
index.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<head>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<style type="text/css">
<?PHP
for($i=0;$i<3;$i++)
{
?>
.top_box<?PHP echo $i; ?>{
left: 99px;
top: 0px;
position: absolute;
border: 1px solid #000;
display: none;
}
<?PHP
}
?>
</style>
<?PHP
for($i=0;$i<3;$i++)
{
?>
<script type="text/javascript">
$(document).ready(function(){
$("#thumbnail<?PHP echo $i ; ?>").hover(
function(){
var id = $(this).data("id");
if(id!==undefined){
$("#" + id).show();
}
$("#top_box<?PHP echo $i; ?>").show();
},function(){
$("#top_box<?PHP echo $i; ?>").hide();
});
});
</script>
<?PHP
}
?>
</head>
<br><br><br><br><br><br><br><br><br><br>
<div style=" float: left; position: relative; width: 100%; margin-bottom: 200px; " >
<div id="top_box0" class="top_box0">
<img src="http://consciouscat.net/wp-content/uploads/2010/02/cat-licks-lips-200px.jpg">
</div>
<span id="thumbnail0" style=" margin: 7px; position: relative;">
<img border="0" src="http://consciouscat.net/wp-content/uploads/2010/02/cat-licks-lips-200px.jpg" width="80" height="80"/>
</span>
</div>
<br>
<div style=" float: left; position: relative; width: 100%; margin-bottom: 200px; " >
<div id="top_box1" class="top_box1">
<img src="http://cat-bounce.com/cb.png">
</div>
<span id="thumbnail1" style=" margin: 7px; position: relative; ">
<img border="0" src="http://cat-bounce.com/cb.png" width="80" height="80"/>
</span>
</div>
<br>
<div style=" float: left; position: relative; width: 100%; margin-bottom: 200px; " >
<div id="top_box2" class="top_box2">
<img src="http://media.yopi.co.th/prod_pics/12/e/12827.jpg">
</div>
<span id="thumbnail2" style=" margin: 7px; position: relative;">
<img border="0" src="http://media.yopi.co.th/prod_pics/12/e/12827.jpg" width="80" height="80"/>
</span>
</div>