gpt4 book ai didi

jquery 对话框和 css 问题给痛苦

转载 作者:行者123 更新时间:2023-11-28 16:47:28 26 4
gpt4 key购买 nike

我正在使用 jquery 对话框,我的 div 通过对话框显示。我的 div 有一个简单的 css,它有背景图像,应该位于 div 的中心。但是当对话框打开时,图像显示但在左侧而不是中心。我无法解决这个问题。 plzz需要帮助。基本上我想在对话框的中心显示图像。

这是我的代码

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="../Styles/ui-lightness/jquery-ui-1.7.2.custom.css" rel="stylesheet" type="text/css" />

<script src="../Scripts/jquery.min.js" type="text/javascript"></script>
<script src="../Scripts/jquery-ui.min.js" type="text/javascript"></script>
<style type="text/css">
.BusyStyles
{
background-image: url('../images/ajax-loader.gif');
background-repeat: no-repeat; background-position: center center;
height: 150px;
width: 250px;
}
</style>

<script language="javascript" type="text/javascript">
$(document).ready(function () {

var _images = ['../images/ajax-loader.gif'];
$.each(_images, function (e) {
$(new Image()).load(function () {
//alert($(this).attr('src') + 'has loaded!');
}).attr('src', this);
});

$("#dialog").dialog({
autoOpen: false,
height: 150,
width: 250,
modal: false,
draggable: false,
resizable: false,

show: {
effect: "fade",
duration: 2000
},
hide: {
effect: "fade",
duration: 500
}

});

$("#btnOpen").click(function () {
$('#dialog').html('<img src="../images/ajax-loader.gif" border="0" />');
$("#dialog").dialog("open");
return false;
});

$("#btnClose").click(function () {
$("#dialog").dialog("close");
return false;
});

}); // doc end
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="dialog" class="BusyStyles">
</div>
<asp:Button ID="btnOpen" runat="server" Text="Open" />

</form>
</body>
</html>

最佳答案

要水平和垂直居中,在你的 CSS 中,添加样式

#dialog {
text-align:center;
padding-top: 22px; /* you can use a padding to vertically center*/
}

编辑:去除 $('#dialog').html('<img src="image.GIF" border="0" />');因为在 BusyStyles Css 中你已经声明了一个背景女巫已经是 center center (并且工作正常)

关于jquery 对话框和 css 问题给痛苦,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7913041/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com