2011-01-31 68 views
1

我嘗試將鏈接樣式化爲JQuery UI按鈕時出現了一個奇怪的問題。它在Chrome中顯示爲按鈕,在Firefox和IE8中顯示爲鏈接。JQuery UI標籤不作爲Firefox和IE中的按鈕樣式

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
     "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
    <script type="text/javascript" src="script/jquery-1.4.2.js"></script> 
    <script type="text/javascript" src="script/jquery-ui-1.8.9.custom.min.js"></script> 
    <link rel="stylesheet" type="test/css" href="stylesheet/jquery-ui-1.8.9.custom.css"> 
    <link rel="stylesheet" type="text/css" href="stylesheet/styles.css"> 
    <script type="text/javascript"> 
     $(document).ready(function(){ 
      $("a").button(); 
     }); 
    </script> 
    <title>Introduction</title> 
</head> 
<body class="indexbody"> 
    <div class="indexwrapper"> 
     <div id="introduction">   
      <div class="btn"> 
       <a href="test.html" >link</a> 
      </div> 
     </div> 
    </div> 
</body> 
</html> 
+0

Firebug有什麼結果?你看到的UI值設置類屬性?你試過什麼了?在湯姆克魯斯的名言中,「幫助我幫助你」。 – jmort253 2011-01-31 03:53:52

+0

Firefox:class =「ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only」Chrome:class =「ui-button」ui-widget「ui-state-default」「ui-corner」 -all ui-button-text-only「 生成的HTML在Firefox和Chrome中完全相同。在IE中沒有應用ui-類。 – 2011-01-31 03:56:33

+0

在Chrome中,我看到一個綠色按鈕(如預期的那樣)。在Firefox和IE中我看到一個鏈接。 – 2011-01-31 04:05:20

回答

3

它看起來像是很容易錯過你的CSS鏈接元素中的錯字。 type屬性應該是text/css,而不是test/css

xs彼此如此接近。

<link rel="stylesheet" type="text/css" 
    href="stylesheet/jquery-ui-1.8.9.custom.css"> 

在Chrome改編後,其他瀏覽器對其語法更加嚴格。 Chrome遵循Robustness Principle

最後,加載CSS或JavaScript的順序似乎沒有關係。鏈接標記可以在腳本元素之前或之後出現。

1

CSS首先包含JS,這應該可以解決您的問題。

<link rel="stylesheet" type="test/css" href="stylesheet/jquery-ui-1.8.9.custom.css"> 
<link rel="stylesheet" type="text/css" href="stylesheet/styles.css"> 
<script type="text/javascript" src="script/jquery-1.4.2.js"></script> 
<script type="text/javascript" src="script/jquery-ui-1.8.9.custom.min.js"></script>