首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >弹出web屏幕的jQuery灯箱/模式窗口

弹出web屏幕的jQuery灯箱/模式窗口
EN

Stack Overflow用户
提问于 2009-07-01 11:24:24
回答 2查看 10.9K关注 0票数 1

在我的web应用程序中,我正在考虑创建一个页面的弹出式屏幕,供用户在其中进行一些处理。

我基本上希望这个页面像一个向下钻取窗口,显示基于您从顶级摘要记录按下的按钮的详细记录。

我想到的不是弹出窗口,而是一个jQuery灯箱功能/模式窗口。

我公开了一些建议和很好的简单的灯箱示例,用于显示网页屏幕,而不是照片,几乎是一个弹出式窗口,但具有jQuery的外观和感觉,即放大到用户,然后缩小到摘要记录。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2009-07-01 13:06:03

试一下这个例子,

代码语言:javascript
运行
复制
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Simple JQuery Modal Window from Queness</title>

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script>
<script>

$(document).ready(function() {  

    //select all the a tag with name equal to modal
    $('a[name=modal]').click(function(e) {
        //Cancel the link behavior
        e.preventDefault();

        //Get the A tag
        var id = $(this).attr('href');

        //Get the screen height and width
        var maskHeight = $(document).height();
        var maskWidth = $(window).width();

        //Set heigth and width to mask to fill up the whole screen
        $('#mask').css({'width':maskWidth,'height':maskHeight});

        //transition effect     
        $('#mask').fadeIn(1000);    
        $('#mask').fadeTo("slow",0.8);  

        //Get the window height and width
        var winH = $(window).height();
        var winW = $(window).width();

        //Set the popup window to center
        $(id).css('top',  winH/2-$(id).height()/2);
        $(id).css('left', winW/2-$(id).width()/2);

        //transition effect
        $(id).fadeIn(2000); 

    });

    //if close button is clicked
    $('.window .close').click(function (e) {
        //Cancel the link behavior
        e.preventDefault();

        $('#mask').hide();
        $('.window').hide();
    });             

});

</script>
<style>
body {
font-family:verdana;
font-size:15px;
}

a {color:#333; text-decoration:none}
a:hover {color:#ccc; text-decoration:none}

#mask {
  position:absolute;
  left:0;
  top:0;
  z-index:9000;
  background-color:#000;
  display:none;
}

#boxes .window {
  position:absolute;
  left:0;
  top:0;
  width:440px;
  height:200px;
  display:none;
  z-index:9999;
  padding:20px;
}

#boxes #dialog {
  width:375px; 
  height:203px;
  padding:10px;
  background-color:#ffffff;
}

</style>
</head>
<body>
<h2>Simple jQuery Modal Window</h2>
<ul>
<li><a href="#dialog" name="modal">Simple Window Modal</a></li>
</ul>

<div id="boxes">
<div id="dialog" class="window">
Simple Modal Window | 
<a href="#"class="close"/>Close it</a>
<p>Anything can go Here</p>
</div>
<!-- Mask to cover the whole screen -->
  <div id="mask"></div>
</div>

</body>
</html>
票数 3
EN

Stack Overflow用户

发布于 2009-07-01 13:25:11

你确定那个屏幕需要是模式的吗?在使用应用程序的其余部分之前,他们在屏幕上所做的操作对他们来说是必要的吗?

否则,你就有可能不恰当地引入模式窗口来损害可用性。试着扩大区域,而不是使用lightbox技术。

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1068586

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档