开发者

Placing div tag at a desired position

All,

In the following code

<html>
<head>
 <link type="text/css" href="http://jqueryui.com/latest/themes/base/ui.all.css" rel="stylesheet" />
 <script type="text/javascript" src="http://jqueryui.com/latest/jquery1.3.2.js">       
</script>

<script src="http://jqueryui.com/latest/ui/effects.core.js"></script>
<script src="http://jqueryui.com/latest/ui/effects.slide.js"></script>
<style type="text/css">
 #show { margin: 0px; width: 100px; height: 80px; background: green; border: 1px solid black; position: relative; }
</style>
<script>
$(document).ready(function(){
$("#details").mouseover(function()开发者_如何学C {
$("#show").show("slide", {}, 1000);
});
</script>

</head>
<body>
<div id="details">keyword</div>
<div id="show" style="display:none;"></div>
</body>

I have to place the show div at the middle of the page on mouseover on details div.Can u tell me how it can be done.....

Thanks.........................


Something like this?

    $("#details").mouseover(function() {
        var theTop = ($(window).height() / 2) - $('#show').height();
        $("#show").show().css({margin:'0 auto', top:theTop});
    });


If you're talking about a lightbox effect, there are lots of jQuery plugins available to handle this for you. Some examples:

http://leandrovieira.com/projects/jquery/lightbox/

http://colorpowered.com/colorbox/

http://jqueryui.com/demos/dialog/


Since you're already using the jQuery UI, I think the dialog component would be an easy way to make it happen.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜