小小的弹出框

只要在需要的div 上加 onclick=showDiv(‘#popPic‘);就可以了

html

<div id="popBox">
    <div class="popCont">
        <a class="closed">关闭</a>
    </div>
</div>

css

body{position: relative;}
#popBox{position: absolute;left: 0;top:0;right: 0;bottom: 0;background: rgba(0,0,0,.5);z-index: 500;display: none;}
.popCont{position: fixed;width: 530px;height: 450px;background: #fff;}
.closed{position: absolute;right: 0;top:0;}

js

<script>
function showDiv(sId){
    var getId=$(sId);
    getId.height($(‘body‘).height());
    getId.stop(true,true).show().stop(true,true).animate({opacity:‘1‘},200);
    var firstDiv=getId.find(‘div:first‘);
    var h=firstDiv.height();
    var w=firstDiv.width();
    firstDiv.css({
        ‘position‘:‘fixed‘,
        ‘left‘:‘50%‘,
        ‘top‘:‘50%‘,
        ‘margin-top‘:-h/2+‘px‘,
        ‘margin-left‘:-w/2+‘px‘
    })
    firstDiv.click(function(e){
        e.stopPropagation();
    });
    getId.click(function(){
        $(this).stop(true,true).hide().stop(true,true).animate({opacity:‘0‘},200);
    });
    $(‘.closed‘).click(function(){
        getId.stop(true,true).hide().stop(true,true).animate({opacity:‘0‘},200);
    });
}
</script>
时间: 2024-08-29 03:46:48

小小的弹出框的相关文章

android 自定义弹出框AlertDialog ,很炫的哦

于是就小小的模仿了下自己写了这个这样的效果,主要代码如下:dlg = new AlertDialog.Builder(context).create();dlg.show();dlg.getWindow().setContentView(R.layout.alert_style);LayoutInflater factory = LayoutInflater.from(context);View view = factory.inflate(R.layout.alert_style, null)

安卓中的弹出框

AlertDialog.Builder builder = new Builder(Context context) 得到一个context所在页面的弹出框, 可以是单选 builder.setSingleChoiceItems(items, checkedItem,listener)  items为弹出框的条目,checkedItem为默认选择的条目(一个),listener为弹出框的点击事件监听器(DialogInterface.OnClickListener的类型,是内部类), 也可以是多

Bootstrap方法为页面添加一个弹出框

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Bootstrap 实例 - 弹出框(Popover)插件</title> <link rel="stylesheet" href="https://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap

popover弹出框

<style> #view{width: 300px;height: 200px;border: 1px solid red;} </style> 以上是为了viewport更容易看出来设置的样式 <body style="margin: 50px;"> <div id="view"> <button class="btn btn-danger btn-lg" data-toogle=&quo

js 常见弹出框学习

模拟系统的弹出框 系统自带的弹出框 总结 链接  http://blog.csdn.net/anhuidelinger/article/details/17024491 参考这个网站学习模态框的动态弹出   http://tympanus.net/codrops/2013/06/25/nifty-modal-window-effects/,网站提供打包好的资源下载. html中的基本结构: <div class="md-modal md-effect-1" id="mo

UIAlertView弹出框

<Alert弹出框提示用户信息>    1.遵循代理方法<UIAlertViewDelete>    2.调用方法UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"恭喜通关!" message:@"更多精彩,请购买下一关~~" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"购买&

UIActionSheet底部弹出框

<底部弹出框来提示用户信息>    1.遵循代理方法<UIActionSheetDelete>    2.调用放法 [UIActionSheet *sheet=[UIActionSheet alloc]initWithTitle:@“通关了!” delegate:self cancelButtonTitle:@“取消” destructiveButtonTitle:@“购买” otherButtonTitles:@“购买1”,@“购买2”,nil]    [sheet showIn

Bootstrap弹出框

弹出框3要素 modal-headermodal-bodymodal-footer <!--促发弹窗--> <a href="#" data-toggle="modal" data-target="#about">点我弹出</a> <!--弹窗代码--> <div class="modal fade" id="about"> <div cla

显示遮罩层和弹出框

因为最近用到了遮罩层和弹出框,上网查资料后自己完成了一个,在此做一下记录做保存. 因为用到了jq,所以需要引入jq文件,比如jquery-1.11.3.js 以下是jsp的代码: <body> <div> <input id="button" type="button" value="点击我"> <div class="shareDialog"> <div class=&q