Позиционирование
Привет!
Есть два DIV'a: <div class="container"> <div class="1"></div> <div class="2"></div> </div> Как узнать TOP между 1ым и 2ым DIV'ом ? |
Цитата:
Тогда как вариант... <!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery-latest.js"></script> <!-- <link rel="stylesheet" type="text/css" href="tmp.css" /> --> <style type="text/css"> * { margin: 0; padding: 0; } .container { margin-top: 15px; } .d2 { background-color: red; } .d1 { margin-bottom: 10px; background-color: green; } </style> <script type="text/javascript"> $(document).ready(function() { var o1=$('.d1').offset(); var h1=$('.d1').height(); var o2=$('.d2').offset(); alert(o2.top-o1.top-h1); }); </script> </head> <body> <table> <div class="container"> <div class="d1">1</div> <div class="d2">2</div> </div> </table> </body> </html> |
Часовой пояс GMT +3, время: 10:51. |