javascript - How to dynamic set top css when element over top page or bottom page? -
javascript - How to dynamic set top css when element over top page or bottom page? -
how dynamic set top css when element on top page or bottom page ?
first , mouse on first cat image. it's ok
http://image.ohozaa.com/i/480/7ypwei.jpg
when scroll page bottom , mouses first cat image 1 time again ,
http://image.ohozaa.com/i/5b5/l2l3dj.jpg
big cat image on top page
and when scroll page top , mouses 3 cat image 1 time again ,
http://image.ohozaa.com/i/5db/ezze1b.jpg
big cat image on bottom page
how alter top css of mouse on effect element not on top page or on bottom page ?
http://jsfiddle.net/l7lyjtp7/
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>
you can set css fixed so: jsfiddle if want cats appear next images can add together jquery calculate if image on "top page"/"bottom page" , set position fixed needed.
.top_box0{ left: 99px; top: 0px; position: fixed; border: 1px solid #000; display: none; } .top_box1{ left: 99px; top: 0px; position: fixed; border: 1px solid #000; display: none; } .top_box2{ left: 99px; top: 0px; position: fixed; border: 1px solid #000; display: none; }
javascript jquery html css
Comments
Post a Comment