写在前面

在实际开发中,为了友好,更需要一种美观的弹出框,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. Blender绘制大脑表层,并高亮染色

    首先, 有必要熟悉一下Blender的一些快捷键.(实在不想吐槽Blender反人类的交互操作了) 按鼠标右键是选择某个物体.(是右键,而不是左键!) 按A键,取消选中或者选中全部物体. 按H键,隐藏 ...

  2. Trades FZU - 2281 (大数+贪心)

    This is a very easy problem. ACMeow loves GTX1920. Now he has m RMB, but no GTX1920s. In the next n ...

  3. Naive Operations HDU多校(线段树上线段果)

    Problem Description In a galaxy far, far away, there are two integer sequence a and b of length n.b ...

  4. 编译skia静态库时,图片解码库无法注册的问题

    转载:http://www.cnblogs.com/imlucky/archive/2012/08/01/2617851.html 今天编译skia库,增加图片解码库时总是无效.按照此博客的方法修改后 ...

  5. 通过psexec实现远程安装软件包

    1.在管理机上下载和安装psexec https://docs.microsoft.com/en-us/sysinternals/downloads/psexec 2.在管理机上编写bat脚本,存放在 ...

  6. Difference between List View and DataGrid in WPF

    Well, in WPF the difference between ListView and DataGrid is just one. Editing. You need editing use ...

  7. 南阳ACM 题目22:素数求和问题

    素数求和问题 时间限制:3000 ms  |  内存限制:65535 KB 难度:2 描述 现在给你N个数(0<N<1000),现在要求你写出一个程序,找出这N个数中的所有素数,并求和. ...

  8. 【设计模式】 模式PK:策略模式VS桥梁模式

    1.概述 我们先来看两种模式的通用类图. 两者之间确实很相似.如果把策略模式的环境角色变更为一个抽象类加一个实现类,或者桥梁模式的抽象角色未实现,只有修正抽象化角色,想想看,这两个类图有什么地方不一样 ...

  9. .net core Fundamentals

    • Application Startup 應用程序啟動 • Middleware 中間件 • Working with Static Files 靜態文件 • Routing 路由 • URL Re ...

  10. 【bzoj1774-过路费】floyd+排序

    题意:n个点,m条双向边,每个点有权值c[i],每条边有权值a[i].d,一条路径的费用=每条边的权值和+各个点的权值的最大值,即sigma(a[i].d)+max(c[i]).q个询问,问x到y的最 ...