2013-07-05 26 views
0

我有,基本上工作的對話框一個簡單的腳本:爲什麼jQuery對話框上的關閉按鈕在與Web頁面集成時向左移動?

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /> 
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script> 
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> 

<script type="text/javascript"> 
$(document).ready(function() { 
    $(function() { $("#dialog").dialog(); 
    }); 
}); 
</script> 
</head> 
<body"> 
<div id="dialog" title="Message"> 
<p>Hello! Did you know you could save 2%</p> 
</div> 
</body> 

但是,它集成到一些網站有時不能很好地工作。請查看鏈接上的區別: http://www.jboston.net/2013/Message1.png 如何修復將關閉按鈕向左移動?

螢火顯示該按鈕的下面的代碼:

<button class="ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only ui-dialog-titlebar-close" role="button" aria-disabled="false" title="close" style="margin-right: 328.5px;"><span class="ui-button-icon-primary ui-icon ui-icon-closethick"></span><span class="ui-button-text">close</span></button> 

所有款式都是從jQuery的ui.css除了一個風格從HTML來:「保證金右:328.5px;」

+1

檢查與調試工具,CSS規則給出了這樣的行爲 –

+0

請參閱問題 –

+0

'保證金右編輯的文本:328.5px ;'解釋確切 –

回答

0

經過一些工作,我放棄了使用jquery-ui對話框。使用jQuery動畫製作我需要的功能是可能的。

HTML:

<div id="admess" style="background: LightCyan; height: 150px; width: 400px; position: absolute;  display:none"> 
<h3>title></h3> 
<h4>message></h4> 
<br/> 
<a id="closead" href="#">Close</a> 
</div> 

的jQuery:

if ($("#admess").length) 
{ 
     $("#admess").animate({ 
      left: $(window).width()/2 - $("#admess").width()/2, 
      top: $("#admess").parent().height()/2 - $("#admess").height()/2, 
      opacity: '1', 
      height: '150px', 
      width: '400px' 
     }); 
     $("#admess").show(); 
} 

$("#closead").click(function() { 
    $("#admess").hide(); 
}); 
相關問題