写在前面

在实际开发中,为了友好,更需要一种美观的弹出框,js原生的alert,很难满足需求。这里推荐一个bootstrap的弹出框。

一个例子

先看效果吧

代码:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>模式弹出框</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
<link href="Css/bootstrap.min.css" rel="stylesheet" />
<script src="JS/jquery.js"></script>
<script src="JS/bootstrap.min.js"></script>
<script> </script>
<style>
.blue {
background-color: #0094ff;
} .text-center {
text-align: center;
}
</style>
</head>
<body>
<input type="button" data-target="#loginModal" data-toggle="modal" name="name" class="form-control bt-red" value="登录" />
<!-- modal -->
<div class="modal fade" id="loginModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header blue">
登录
</div>
<div class="modal-body">
<input type="text" class="form-control" placeholder="请输入用户名" name="name" />
<input type="password" class="form-control" placeholder="请输入密码" value="新建文件夹" name="name" />
</div>
<div class="modal-footer">
<div class="form-control text-center">登录</div>
<div class="form-control text-center" data-dismiss="modal"><div class="button"></div>取消</div>
</div>
</div>
</div>
</div>
</body>
</html>

注意

data-target属性,指向了model的id,所以点击按钮,model就会弹出来了。

用js也可以来控制

<script>
$("#btnLogin").click(function () {
//显示
$("#loginModal").modal("show");
//隐藏
$('#loginModal').modal('hide');
//切换
$('#myModal').modal('toogle');
});
</script>

总结

之所以推荐这个弹出框,是因为这个操作更方便,因为在项目中用到bootstrap,这样也不需要再去添加其他的引用了。如果用来作为提示框,可以修改modal-body中的内容为字符串就可以了。

[Bootstrap]modal弹出框的更多相关文章

  1. Bootstrap:弹出框和提示框效果以及代码展示

    前言:对于Web开发人员,弹出框和提示框的使用肯定不会陌生,比如常见的表格新增和编辑功能,一般常见的主要有两种处理方式:行内编辑和弹出框编辑.在增加用户体验方面,弹出框和提示框起着重要的作用,如果你的 ...

  2. JS组件Bootstrap实现弹出框和提示框效果代码

    这篇文章主要介绍了JS组件Bootstrap实现弹出框和提示框效果代码,对弹出框和提示框感兴趣的小伙伴们可以参考一下 前言:对于Web开发人员,弹出框和提示框的使用肯定不会陌生,比如常见的表格新增和编 ...

  3. Bootstrap模态弹出框

    前面的话 在 Bootstrap 框架中把模态弹出框统一称为 Modal.这种弹出框效果在大多数 Web 网站的交互中都可见.比如点击一个按钮弹出一个框,弹出的框可能是一段文件描述,也可能带有按钮操作 ...

  4. Bootboxjs快速制作Bootstrap的弹出框效果

    Bootboxjs是一个简单的js库,简单快捷帮你制作一个Bootstrap的弹出框效果. 一.简介 bootbox.js是一个小的JavaScript库,它帮助您在使用bootstrap框架的时候快 ...

  5. Bootstrap实现弹出框和提示框效果代码

    一.Bootstrap弹出框使用过JQuery UI应该知道,它里面有一个dialog的弹出框组件,功能也很丰富.与jQuery UI的dialog类似,Bootstrap里面也内置了弹出框组件.打开 ...

  6. Bootstrap popover弹出框

    popover被挤压.遮挡的问题: 弹出框显示的时候如果贴近一个列的边沿,就会很窄或被遮挡,解决起来很简单,只需在初始化的时候添加一个container属性就可以了: $(function (){ $ ...

  7. 自定义Bootstrap样式弹出框

    最近做的一些功能需要用到Bootstrap,然而原来的系统并没有引入Bootstrap,为了新写的控件能够应用于老的页面,又不需要在老的页面上引入全套的Bootstrap文件决定写一个模仿Bootst ...

  8. bootstrap的弹出框

    data-toggle="popover";//以弹出框事件触发 data-content="弹出框中内容"; data-placement="弹出框 ...

  9. firefox浏览器中 bootstrap 静态弹出框中select下拉框不能弹出(解决方案)

    问题出现场景1: 在firefox浏览器中在bootstrap弹出的modal静态框中再次弹出一个静态框时 select下拉框不能弹出选项 解决方案:去掉最外层静态框的 tabindex=" ...

随机推荐

  1. android 应用使用Root权限执行linux命令

    要让Android应用使用Root权限,首先Android设备必须已经获得Root权限.之后可以通过下面的代码取得process对象. Process process = Runtime.getRun ...

  2. bug report

    ubuntu 11.10添加eth0:1后重启网卡不显示 eth0:1 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=324306

  3. BZOJ1105 [POI2007]石头花园SKA 贪心

    [POI2007]石头花园SKA Time Limit: 20 Sec  Memory Limit: 162 MBSubmit: 776  Solved: 237[Submit][Status][Di ...

  4. maven中net.sf.json报错的解决方法(转载)

    原文:http://www.cnblogs.com/winner-0715/p/5928514.html 今天在用maven添加net.sf.json的jar包的时候,代码如下: <depend ...

  5. 深入探索C++对象模型(二)

    构造函数语义学(The Semantics of Constructors) Default Constructor的构造操作 对于class X,如果没有任何user-declared constr ...

  6. npm 淘宝镜像安装以及安装报错window_nt 6.1.7601 解决

    http://www.cnblogs.com/ycxhandsome/p/6562980.html npm config set proxy null npm config set https-pro ...

  7. PHP扩展--APC缓存安装与使用

    apc安装 wget http://pecl.php.net/get/APC-3.1.13.tgz tar zxvf APC-3.1.13.tgz cd APC-3.1.13 /usr/local/p ...

  8. Ant复制文件

    <?xml version="1.0" encoding="UTF-8"?> <project name ="test" ...

  9. asp.net RDLC报表入门

    Asp.net RDLC 报表入门 这几天帮给同事讲解Asp.net RDLC 报表方面的知识,顺便做个简单教程,在这里分享给大家. 由于图片多又大,写了一半,光上传图片就把我累个半死,所以我教把程放 ...

  10. 如何设计一个优雅健壮的Android WebView?(上)

    转:如何设计一个优雅健壮的Android WebView?(上) 前言 Android应用层的开发有几大模块,其中WebView是最重要的模块之一.网上能够搜索到的WebView资料可谓寥寥,Gith ...