如何控制jquery ui弹窗下方按钮水平居中
1、问题背景
一般情况下,jquery ui弹窗下方的按钮是居右的,但是有时系统为了达到美观统一,需要将按钮放在中间
2、问题原因
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>如何使jquery ui弹窗下方按钮水平居中</title>
<link rel="stylesheet" href="../js/jquery-ui-1.10.4/themes/base/jquery.ui.all.css">
<script src="../js/jquery-ui-1.10.4/jquery-1.10.2.js"></script>
<script src="../js/jquery-ui-1.10.4/ui/jquery-ui.js"></script>
<style>
.ui-progressbar {
height: 10px;
}
#dialogFile {
min-height: 0px !important;
}
</style>
<script>
$(function() {
$("#dialogInfo").dialog({
resizable: false,
title: '新增',
height: 500,
width: 420,
modal: true,
buttons: {
"关闭": function() {
$(this).dialog("close");
}
}
});
$("#dialogFile").dialog({
autoOpen: false,
closeOnEscape: false,
resizable: false,
modal:true
});
$("#progressbar").progressbar({
value: false,
complete: function() {
$(".ui-dialog button").last().trigger("focus");
}
});
});
function openWin(obj) {
var fileUpload = $(obj).val();
checkFileSize(obj);
if(fileUpload) {
$("#dialogFile").prev().css("display","none");
$("#dialogFile").dialog("open");
}
}
function checkFileSize(obj)
{
var filePath = $(obj).val();
var fileStart = filePath.lastIndexOf(".");
var endFile = filePath.substring(fileStart, filePath.length).toUpperCase();
if(endFile != ".PNG" && endFile != ".JPG" && endFile != ".GIF")
{
hiAlert("文件限于png,jpg或gif格式");
return false;
}
var img = new Image();
img.src = filePath;
if(img.fileSize > 0)
{
if(img.fileSize > 20 * 1024 * 1024)
{
hiAlert("上传的文件大小不能超过20M!");
return false;
}
}
return true;
}
</script>
</head>
<body>
<div id="dialogInfo" title="弹窗信息">
<input type="file" onchange="openWin(this);" />
</div>
<div id="dialogFile" style="height:50px;width:290px;">
<div class="progress-label" style="width:100%;text-align:center;">正在上传...</div>
<div id="progressbar"></div>
</div>
</body>
</html>
3、解决办法
需要添加样式
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>如何使jquery ui弹窗下方按钮水平居中</title>
<link rel="stylesheet" href="../js/jquery-ui-1.10.4/themes/base/jquery.ui.all.css">
<script src="../js/jquery-ui-1.10.4/jquery-1.10.2.js"></script>
<script src="../js/jquery-ui-1.10.4/ui/jquery-ui.js"></script>
<style>
.ui-progressbar {
height: 10px;
}
#dialogFile {
min-height: 0px !important;
}
.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset{
text-align: center;
float: none;
}
</style>
<script>
$(function() {
$("#dialogInfo").dialog({
resizable: false,
title: '新增',
height: 500,
width: 420,
modal: true,
buttons: {
"关闭": function() {
$(this).dialog("close");
}
}
});
$("#dialogFile").dialog({
autoOpen: false,
closeOnEscape: false,
resizable: false,
modal:true
});
$("#progressbar").progressbar({
value: false,
complete: function() {
$(".ui-dialog button").last().trigger("focus");
}
});
});
function openWin(obj) {
var fileUpload = $(obj).val();
checkFileSize(obj);
if(fileUpload) {
$("#dialogFile").prev().css("display","none");
$("#dialogFile").dialog("open");
}
}
function checkFileSize(obj)
{
var filePath = $(obj).val();
var fileStart = filePath.lastIndexOf(".");
var endFile = filePath.substring(fileStart, filePath.length).toUpperCase();
if(endFile != ".PNG" && endFile != ".JPG" && endFile != ".GIF")
{
hiAlert("文件限于png,jpg或gif格式");
return false;
}
var img = new Image();
img.src = filePath;
if(img.fileSize > 0)
{
if(img.fileSize > 20 * 1024 * 1024)
{
hiAlert("上传的文件大小不能超过20M!");
return false;
}
}
return true;
}
</script>
</head>
<body>
<div id="dialogInfo" title="弹窗信息">
<input type="file" onchange="openWin(this);" />
</div>
<div id="dialogFile" style="height:50px;width:290px;">
<div class="progress-label" style="width:100%;text-align:center;">正在上传...</div>
<div id="progressbar"></div>
</div>
</body>
</html>
.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset{
text-align: center;
float: none;
}
如何控制jquery ui弹窗下方按钮水平居中的更多相关文章
- JQuery UI dialog 弹窗实例及参数说明
按钮代码: <a id="suprise" style="margin-left: 0.5em;cursor:pointer;">点我会有惊喜< ...
- 弹窗中使用jquery ui的autocomplete自动完成插件无效果 实际是被遮挡了
在普通页面上使用jquery ui的autocomplete自动完成插件时正常显示提供选择的下拉框,但是放到弹窗中的时候就无法显示这个选择的下拉框,其它效果正常: 估计是被弹出窗遮挡了,网络搜索了jq ...
- [前端]使用JQuery UI Layout Plug-in布局 - wolfy
引言 使用JQuery UI Layout Plug-in布局框架实现快速布局,用起来还是挺方便的,稍微研究了一下,就能上手,关于该布局框架的材料,网上也挺多的.在项目中也使用到了,不过那是前端的工作 ...
- 三、jQuery--jQuery基础--jQuery基础课程--第10章 jQuery UI型插件
1.拖曳插件——draggable 拖曳插件draggable的功能是拖动被绑定的元素,当这个jQuery UI插件与元素绑定后,可以通过调用draggable()方法,实现各种拖曳元素的效果,调用格 ...
- 【jQuery UI 1.8 The User Interface Library for jQuery】.学习笔记.6.Dialog控件
习惯上,我们播放一条简短的信息,或向浏览者询问一个问题,都会用到dialog. 创建一个基本的dialog 使用dialog 选项 形式 启用内置动画 给dialog添加按钮 使用dialog回调函数 ...
- jQuery UI 日期控件--datepicker
在web开发中,日期的输入经常会遇到.我们会用的解决方法有: 1.自己写css和js,对日期进行控制:----有点浪费精力和时间: 2.用easyui插件中的日期插件来实现: 3.用juqery-ui ...
- [转载]jQuery UI 使用
最近项目中使用了一些插件来做页面,这里把jQuery UI的使用分享出来,希望 对新手有帮助.文章结尾附源码下载. 1 jQuery UI 2 为我所用 2.1 Tabs 2. ...
- jQuery Tools:Web开发必备的 jQuery UI 库
基本介绍 jQuery Tools 是基于 jQuery 开发的网站界面库,包含网站最常用的Tabs(选项卡).Tooltip(信息提示).Overlay(遮罩.弹窗).Scrollable(滚动控制 ...
- jQuery UI框架
jQuery UI框架 1.oschina开源社区-jQuery教程 2.jQuery PrimeUI(推荐) 3.弹出框.警告框.提示框.拖动支持.位置固定.选项卡切换 4.Bootstrap框架( ...
随机推荐
- Spring 入门 web.xml配置详解
Spring 入门 web.xml配置详解 https://www.cnblogs.com/cczz_11/p/4363314.html https://blog.csdn.net/hellolove ...
- C#类头部声明样式
/******************************************************************** * * 使本项目源码前请仔细阅读以下协议内容,如果你同意以下 ...
- 【Python】【问题集锦】
1. 用pycharm安装第三方包失败,报类似于“sort"的错误,就转战终端 2. Mac终端安装第三包失败,报类似于“ PermissionError: [Errno 13] Permi ...
- spoj TBATTLE 质因数分解+二分
题目链接:点击传送 TBATTLE - Thor vs Frost Giants #number-theory #sliding-window-1 Thor is caught up in a fie ...
- SQLServer随机取记录
SQLServer本身并没有提供随机读取记录的功能,但我们可以通过一些方法来实现这个目的.本文介绍了其中几种方法并比较了各自的优劣. 方法一:直接通过Sql语句实现,如: SELECT TOP 100 ...
- 如何优化myeclipse.
1.去除不需要加载的模块 一个系统20%的功能往往能够满足80%的需求,MyEclipse也不例外,我们在大多数时候只需要20%的系统功能,所以可以将一些不使用的 模块禁止 加载启动.通过Window ...
- 推荐一款基于Angular实现的企业级中后台前端/设计解决方案脚手架
ng-alain 是一个企业级中后台前端/设计解决方案脚手架,我们秉承 Ant Design 的设计价值观,目标也非常简单,希望在Angular上面开发企业后台更简单.更快速.随着『设计者』的不断反馈 ...
- Unity2017烘焙参数设置
- Maven常用dependency记录
1.servlet配置 <dependency> <groupId>junit</groupId> <artifactId>junit</arti ...
- asp.net一般处理程序利用反射定位方法
asp.net的一般处理程序我想大家用得都不少,经常会如下如下的代码: using System; using System.Collections.Generic; using System.Lin ...