jquery层居中,点击小图查看大图,弹出层居中代码
http://www.cnblogs.com/simpledev/p/3566280.html

见第一版,发现一个情况,如果页面内容多出一屏的情况下,点击查看图片的时候,弹出的层图片在最上面居中,并没有在当前的滚动栏处屏幕居中。修改代码如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript" src="jquery-1.9.1.js"></script> <script type="text/javascript">
$(function() {
$(".aboutus_img").click(function(){ //加入一个DIV(暗层),加入BODY中
var background = $("<div></div>"); $(background).attr("id","overlaybackground").animate({
'opacity':'.6'
},0).css({
"width" : $(document).width(),
'height' : $(document).height(),
'background' : '#656565',
'z-index' : '100',
'position': 'absolute',
'top' : '0px',
'left' : '0px'
});
$("body").append(background); //将加入一个图片
var newimage = $("<img/>");
var width = $('body').width(); $(newimage).attr("src",$(this).attr("src")).attr("id","largeimage").css({
'left' : width/2-200,
'top' : '160px',
//'position': 'absolute',
'position': 'fixed',
'z-index' : '500',
'display' : 'none'
});
$("#largeimage").attr("src",$(this).attr("src")); //重新赋予值
$("body").append(newimage); //将图片滑出效果完成
$("#largeimage").fadeIn(2000,function(){
$(this).click(function(){
$(this).fadeOut(1000);
$("div#overlaybackground").fadeOut(1000,function(){
$(this).remove();
})
})
}) });
})
</script> <style type="text/css">
#low_right
{
position: fixed;
width: 98%;
text-align: center;
}
</style> </head>
<body>
<div id="low_right" align="center">
导航栏固定在顶部位置
<img src="1.jpg" alt="楼" class="aboutus_img" width="58" height="58"/>
<img src="2.jpg" alt="楼" class="aboutus_img" width="58" height="58"/>
</div> <br/><br/> <br/><br/>
<img src="1.jpg" alt="楼" class="aboutus_img" width="58" height="58"/>
<img src="1.jpg" alt="楼" class="aboutus_img" width="58" height="58"/>
<img src="1.jpg" alt="楼" class="aboutus_img" width="58" height="58"/>
<img src="1.jpg" alt="楼" class="aboutus_img" width="58" height="58"/>
<img src="1.jpg" alt="楼" class="aboutus_img" width="58" height="58"/>
<br/><br/><br/><br/>
<img src="2.jpg" alt="楼" class="aboutus_img" width="58" height="58"/>
<img src="2.jpg" alt="楼" class="aboutus_img" width="58" height="58"/>
<img src="2.jpg" alt="楼" class="aboutus_img" width="58" height="58"/>
<img src="2.jpg" alt="楼" class="aboutus_img" width="58" height="58"/>
<img src="2.jpg" alt="楼" class="aboutus_img" width="58" height="58"/>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/>
<img src="2.jpg" alt="楼" class="aboutus_img" width="58" height="58"/>
</body>
</html>

主要修改://'position': 'absolute',
            'position': 'fixed',  改成固定位置,而不是相对位置。

样式low_right控制层不管滚动栏拉到下面,层一直固定在顶部。 另外:ie9浏览器如果没有顶部说明<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 这个效果出不来。在google,firefox浏览器中没有问题。

jquery层居中,点击小图查看大图,弹出层居中代码,顶部层固定不动,滚动条滚动情况的更多相关文章

  1. jquery层居中,点击小图查看大图,弹出层居中代码

    1.层居中 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w ...

  2. 点击小图查看大图jQuery插件FancyBox魔幻灯箱

    今日发现一个不错的JQuery插件FancyBox,也许早就有这个插件了,但是没名字,我就暂且叫他魔幻灯箱吧,采用Mac系统的样式.网传主要有以下功能:■弹出的窗口有很漂亮的阴影效果.■关联的对象(就 ...

  3. 点击图片查看大图(纯js)

    $(function(){ $(".pimg").click(function(){ var _this = $(this);//将当前的pimg元素作为_this传入函数 img ...

  4. android开发:点击缩略图查看大图

    android中点击缩略图查看大图的方法一般有两种,一种是想新浪微博list页面那样,弹出一个窗口显示大图(原activity为背景).另一种就是直接打开一个新的activity显示大图. 1.第一种 ...

  5. Jquery使用mouseenter和mouseleave实现鼠标经过弹出层且可以点击

    <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Jquery使用mousee ...

  6. js的事件冒泡和点击其他区域隐藏弹出层

    一.前言 在编写页面的时候,我们经常使用到弹出层.对于弹出层,原本的意义就是增加与用户的交互,提升用户的好感度.如果弹出层都没有较好的体验,那何谈通过交互来提升好感... 首先提出几个弹出层的注意点: ...

  7. Jquery和Javascript 实际项目中写法基础-弹出窗和弹出层 (4)

     一.实际项目中有很多如下界面效果.    二.该效果可以归结为弹出窗或者弹出层来实现的,为什么这么说?看如下代码:      <!DOCTYPE html> <html> & ...

  8. jQuery弹出窗口完整代码

    jQuery弹出窗口完整代码 效果体验:http://keleyi.com/keleyi/phtml/jqtexiao/1.htm 1 <!DOCTYPE html PUBLIC "- ...

  9. 基于jQuery图片弹出翻转特效代码

    分享一款基于jQuery图片弹出翻转特效代码.这是一款基于jQuery+HTML5实现的,里面包含六款不同效果的鼠标点击图片弹出特效下载.效果图如下: 在线预览   源码下载 实现的代码. html代 ...

随机推荐

  1. Spring IoC容器的设计—1—主线

    IoC容器的接口设计图 下面对接口关系做一些简要的分析,可以依据以下内容来理解这张接口设计图. 从接口BeanFactory到HierarchicalBeanFactory,再到Configurabl ...

  2. 【风马一族_git_github】git与github的英文记录

    Pull requests  Issues Gist 请求 问题 要点 ---------------------------------------------------------------- ...

  3. 《Apache数据传输加密、证书的制作》——涉及HTTPS协议

    首先了解http和https: HTTPS(Secure Hypertext Transfer Protocol)安全超文本传输协议. HTTPS和HTTP的区别: http是超文本传输协议,信息是明 ...

  4. zedboard OPENCV移植

    1:系统环境搭建 要准备好交叉编译环境 见http://blog.csdn.net/xiabodan/article/details/22717175 2:下载cmake CMake是一个跨平台的安装 ...

  5. Node.js学习资料整理

    了解node,node主要能干啥? Node.js究竟是什么?:http://www.ibm.com/developerworks/cn/opensource/os-nodejs/ nodejs教程: ...

  6. ASP.Net网站部署失败

    部署站点时候,出现如下错误 “/”应用程序中的服务器错误. ---------------------------------------------------------------------- ...

  7. 看部电影,透透彻彻理解IoC(你没有理由再迷惑!)

    引述:IoC(控制反转:Inverse of Control)是Spring容器的内核,AOP.声明式事务等功能在此基础上开花结果.但是IoC这个重要的概念却比较晦涩隐讳,不容易让人望文生义,这不能不 ...

  8. Git命令收集【不断更新中】

    git stash 可以用来保存暂时不想提交但又被修改过的文件. git stash pop 用来取出被保存在stash栈中的修改过的所有文件. git stash show 查询哪些文件被存放在了s ...

  9. Highcharts条形与柱形同时显示

    var chart; $(function() { chart = new Highcharts.Chart({ chart: { renderTo: 'chart_combo' //关联页面元素di ...

  10. 忘记linux root密码怎么办?

    摘自:<鸟哥的Linux私房菜> 常常有些朋友在配置好了Linux之后,结果root密码给他忘记去!要重新安装吗?不需要的, 你只要以单人维护模式登陆即可更改你的root密码喔!由于lil ...