Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/396.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 页面加载时灯箱中的可单击图像_Javascript_Jquery_Lightbox - Fatal编程技术网

Javascript 页面加载时灯箱中的可单击图像

Javascript 页面加载时灯箱中的可单击图像,javascript,jquery,lightbox,Javascript,Jquery,Lightbox,我是网络开发新手 我需要一个样本代码,显示一个在页面上加载一个关闭按钮灯箱点击图像。另外,如果有办法的话,我需要它只在桌面浏览器上显示(避免任何移动设备),并且每天每个用户IP显示5倍 有人能帮忙吗 谢谢。灯箱只是盒子中盒子的DIV结构(DIV中的DIV),最外面的DIV有css位置:fixed;z指数:2 以上注意事项:(a)位置也可以是绝对,但灯箱将随页面滚动,并且(b)灯箱的z-index应高于灯箱下方任何其他元素的z-index 与页面上的任何其他HTML元素一样,lightbox di

我是网络开发新手

我需要一个样本代码,显示一个在页面上加载一个关闭按钮灯箱点击图像。另外,如果有办法的话,我需要它只在桌面浏览器上显示(避免任何移动设备),并且每天每个用户IP显示5倍

有人能帮忙吗


谢谢。

灯箱只是盒子中盒子的DIV结构(DIV中的DIV),最外面的DIV有css
位置:fixed;z指数:2

以上注意事项:(a)位置也可以是
绝对
,但灯箱将随页面滚动,并且(b)灯箱的
z-index
应高于灯箱下方任何其他元素的z-index

与页面上的任何其他HTML元素一样,lightbox div结构将是可见的,除非显式地使其不可见(例如,使用
display:none;
或jQuery
hide()
fadeOut()
等),因此lightbox在默认情况下是可见的,然后您可以使用javascript/jQuery在单击按钮时隐藏它:

$('.lb_close')。单击(函数(){
$('#overlay,#lb').fadeOut();
});
$('lb#body_top img')。单击(函数(){
警报(“您单击了图片”);
});
div{位置:相对;框大小:边框框;}
#覆盖{位置:固定;顶部:0;左侧:0;右侧:0;底部:0;背景:黑色;不透明度:0.7;z索引:1;}
#lb{位置:固定;顶部:30px;左侧:20%;宽度:300px;高度:300px;z索引:2;}
#lb#U hdr{高度:30px;宽度:100%;溢出:隐藏;背景:#333;颜色:白色;}
#lb_hdr_标题{浮动:左;高度:100%;宽度:90%;填充:5px;}
#lb_hdr_close{float:左;高度:100%;宽度:10%;}
.lb_close{填充:5px;背景:dodgerblue;颜色:白色;文本对齐:居中;光标:指针;}
#lb_主体{高度:250px;宽度:100%;}
#lb_body_top{高度:200px;宽度:100%;}
#lb_body_bot{高度:50px;宽度:100%;背景:白色;}
#lb_bot_btn{位置:绝对;右侧:20px;高度:50px;宽度:80px;}
按钮{宽度:100%;高度:30px;背景:淡蓝色;颜色:白色;}

这是标题
X
接近
三千年智慧文学

儿子头脑冷静的人是幸福的;悲伤是一个叛逆者的母亲。 2不义之财不会带来持久的幸福;正确的生活。 懒惰的人很快就会变穷;勤劳的人致富。 一个聪明的年轻人在阳光明媚的时候晒干草,但是看到一个年轻人把机会浪费在睡觉上,真是太可惜了。 (英译汉)好人从头到脚都充满了祝福,而坏人却在内心诅咒自己的运气。 我们都有美好的回忆,美好的人得到了回报,但恶人的名字在他们之后臭名昭著。 智慧人乐意受教,自足的愚昧人却俯伏在地。 好人站稳脚跟,骗子会滑倒。 好人所说的话是活的真理,恶人的口却满了咒诅。 仇恨能挑起旧日的争吵,但爱能忽视侮辱。 13个有常识的人被尊为顾问;没有它的人被打成仆人。 智者缄口不言。只有傻瓜才会脱口而出他所知道的一切;那只会带来悲伤和麻烦。 富人的财富是他唯一的力量。这个穷人的贫穷是他唯一的诅咒。 17任何愿意被纠正的人都在通往生命的道路上。任何拒绝的人都失去了机会。 18隐藏仇恨就是说谎;诽谤就是愚人。 不要说那么多。你一直把脚放在嘴里。理智一点,关掉水流! 好人说话值得听,但傻瓜的话却微不足道。 21敬虔的人出好主意,悖逆的人因缺乏常识而灭亡。 23愚人的乐趣是做坏事;聪明人的乐趣在于聪明! 恶人的恐惧都会成真,好人的希望也会成真。 25灾祸如旋风袭来,恶人被旋风卷走。但是好人有坚强的锚。 懒惰的人对他的雇主来说是一种痛苦,就像他们眼中的烟或是使他们牙齿紧绷的醋。
将所有文件合并为一个文件

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <style>
        div{position:relative;box-sizing:border-box;}
        #overlay{position:fixed;top:0;left:0;right:0;bottom:0;background:black;opacity:0.7;z-index:1;}
        #lb{position:fixed;top:30px;left:20%;width:300px;height:300px;z-index:2;}
          #lb_hdr{height:30px;width:100%;overflow:hidden;background:#333;color:white;}
            #lb_hdr_title{float:left;height:100%;width:90%;padding:5px;}
            #lb_hdr_close{float:left;height:100%;width:10%;}
              .lb_close{padding:5px;background:dodgerblue;color:white;text-align:center;cursor:pointer;}
          #lb_body{height:250px;width:100%;}
            #lb_body_top{height:200px;width:100%;}
            #lb_body_bot{height:50px;width:100%;background:white;}
              #lb_bot_btn{position:absolute;right:20px;height:50px;width:80px;}
                button{width:100%;height:30px;background:dodgerblue;color:white;}
    </style>
    <script>
        $(function(){
            $('.lb_close').click(function(){
              $('#overlay, #lb').fadeOut();
            });

            $('#lb_body_top img').click(function(){
              alert('You clicked the picture');
            });
        });//END document.ready
    </script>
</head>
<body>
<div id="overlay"></div>
<div id="lb">
  <div id="lb_hdr">
    <div id="lb_hdr_title">Here is the title</div>
    <div id="lb_hdr_close"><div class="lb_close">X</div></div>
  </div><!-- #lb_hdr -->
  <div id="lb_body">
    <div id="lb_body_top">
      <img src="http://placeimg.com/300/200/animals">
    </div><!-- _lb_body_top -->
    <div id="lb_body_bot">
      <div id="lb_bot_btn">
        <button class="lb_close">Close</button>
      </div><!-- #lb_bot_btn -->
    </div><!-- #lb_body_bot -->
  </div><!-- #lb_body -->
</div><!-- #lb -->

<div id="wrap">
Three Thousand Year Old Wisdom Literature<br><br>
1 Happy is the man with a level-headed son; sad the mother of a rebel.

2 Ill-gotten gain brings no lasting happiness; right living does.

4 Lazy men are soon poor; hard workers get rich.

5 A wise youth makes hay while the sun shines, but what a shame to see a lad who sleeps away his hour of opportunity.

6 The good man is covered with blessings from head to foot, but an evil man inwardly curses his luck.

7 We all have happy memories of good men gone to their reward, but the names of wicked men stink after them.

8 The wise man is glad to be instructed, but a self-sufficient fool falls flat on his face.

9 A good man has firm footing, but a crook will slip and fall.

11 There is living truth in what a good man says, but the mouth of the evil man is filled with curses.

12 Hatred stirs old quarrels, but love overlooks insults.

13 Men with common sense are admired as counselors; those without it are beaten as servants.

14 A wise man holds his tongue. Only a fool blurts out everything he knows; that only leads to sorrow and trouble.

15 The rich man’s wealth is his only strength. The poor man’s poverty is his only curse.

17 Anyone willing to be corrected is on the pathway to life. Anyone refusing has lost his chance.

18 To hide hatred is to be a liar; to slander is to be a fool.

19 Don’t talk so much. You keep putting your foot in your mouth. Be sensible and turn off the flow!

20 When a good man speaks, he is worth listening to, but the words of fools are a dime a dozen.

21 A godly man gives good advice, but a rebel is destroyed by lack of common sense.

23 A fool’s fun is being bad; a wise man’s fun is being wise!

24 The wicked man’s fears will all come true and so will the good man’s hopes.

25 Disaster strikes like a cyclone and the wicked are whirled away. But the good man has a strong anchor.

26 A lazy fellow is a pain to his employers—like smoke in their eyes or vinegar that sets the teeth on edge.
</div><!-- #wrap -->

</body>
</html>

div{位置:相对;框大小:边框框;}
#覆盖{位置:固定;顶部:0;左侧:0;右侧:0;底部:0;背景:黑色;不透明度:0.7;z索引:1;}
#lb{位置:固定;顶部:30px;左侧:20%;宽度:300px;高度:300px;z索引:2;}
#lb#U hdr{高度:30px;宽度:100%;溢出:隐藏;背景:#333;颜色:白色;}
#lb_hdr_标题{浮动:左;高度:100%;宽度:90%;填充:5px;}
#lb_hdr_close{float:左;高度:100%;宽度:10%;}
.lb_close{填充:5px;背景:dodgerblue;颜色:白色;文本对齐:居中;光标:指针;}
#lb_主体{高度:250px;宽度:100%;}
#lb_body_top{高度:200px;宽度:100%;}
#lb_body_bot{高度:50px;宽度:100%;背景:白色;}
#lb_bot_btn{位置:绝对;右侧:20px;高度:50px;宽度:80px;}
按钮{宽度:100%;高度:30px;背景:淡蓝色;颜色:白色;}
$(函数(){
$('.lb_close')。单击(函数(){
$('#overlay,#lb').fadeOut();
});
$('lb#body_top img')。单击(函数(){
警报(“您单击了图片”);
});
});//结束文件.ready
这是标题
X
接近
三千年智慧文学

儿子头脑冷静的人是幸福的;悲伤是一个叛逆者的母亲。 2不义之财不会带来持久的幸福;正确的生活。 懒惰的人很快就会变穷;勤劳的人致富。 一个聪明的年轻人在阳光明媚的时候晒干草,但是看到一个年轻人把机会浪费在睡觉上,真是太可惜了。 (英译汉)好人从头到脚都充满了祝福,而坏人却在内心诅咒自己的运气。 我们都有哈