2013-07-23 45 views
0

我不明白這裏有什麼問題。無法讓jQuery Resizable API在html表上工作

我猜jQuery可調整大小與我的表不兼容,因爲CSS?那是不對的。我在這裏錯過了什麼?

這裏是我的html代碼:

<!DOCTYPE html> 

<html> 

<head> 
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> 
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script> 

<style type="text/css"> 
#data_container { 
     height: 175px; 
     position: relative; 

     border: 1px solid #808080; 

     scrollbar-base-color: #DFDFDF; 
     scrollbar-arrow-color: #235A81; 
     overflow-y: scroll; 
     overflow-x: scroll; 
     margin-top: 5px; 

} 

#data { 
     color: rgb(11,63,113); 
     font-family: Arial; 
     font-size: 9pt; 
     border: 0px; 
     width: 100%; 
     table-layout: fixed; 
} 

#data th, #data td { 
     border-bottom: 1px solid #808080; 
     border-right: 1px solid #808080; 
     padding: 3px; 
     width: 150px; 
} 

#data th { 
     filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#ffffff", endColorstr="#cdcdcd"); 
     height: 18px; 
     border-bottom: 1px solid #808080; 
     border-top: 0px; 
} 
#data thead tr { 
     top: expression(this.offsetParent.scrollTop); 
     position: relative; 
} 
#data tr.normal td { 
    color: #235A81; 
    background-color: white; 
} 
#data tr.highlighted td { 
    color: #FFFFFF; 
    background-color: #235A81; 
} 
</style> 



</head> 

<body> 
<div id="data_container"> 
<table id="data" cellspacing="0" cellpadding="0"> 
        <thead> 
          <tr> 
           <th>HEADER 1</th> 
           <th>HEADER 2</th> 
           <th>HEADER 3</th> 
           <th>HEADER 4</th> 
           <th>HEADER 5</th> 
           <th>HEADER 6</th> 
           <th>HEADER 7</th> 
           <th>HEADER 8</th> 
          <tr> 
        </thead> 
        <tbody> 
          <tr> 
           <td>content 1</td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
          <tr> 
          <tr> 
           <td>content 2</td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
          <tr> 
          <tr> 
           <td>content 3</td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
          <tr> 
          <tr> 
           <td>content 4</td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
          <tr> 
          <tr> 
           <td>content 5</td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
          <tr> 
          <tr> 
           <td>content 6</td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
          <tr> 
          <tr> 
           <td>content 7</td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
          <tr> 
          <tr> 
           <td>content 8</td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
          <tr> 
          <tr> 
           <td>content 9</td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
          <tr> 
          <tr> 
           <td>content 10</td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
          <tr> 
          <tr> 
           <td>content 11</td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
          <tr> 
          <tr> 
           <td>content 12</td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
          <tr> 
          <tr> 
           <td>content 13</td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
          <tr> 
          <tr> 
           <td>content 14</td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
          <tr> 
          <tr> 
           <td>content 15</td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
           <td>content </td> 
          <tr> 
        </tbody> 
       </table> 
        <script> 
    $(function() { 
    $("#data tr th").resizable({ 
     handles: 'e' 
    }); 
    }); 
    </script> 
    </div> 
</body> 

</html> 

回答

0

我一行一行地玩CSS,看看可能發生了什麼變化,這會使jQuery與CSS不兼容。

改變從行:

#data thead tr { 
     top: expression(this.offsetParent.scrollTop); 
     position: relative; 
} 

到:

#data th tr { 
     top: expression(this.offsetParent.scrollTop); 
     position: relative; 
} 
0

如果您卸下的TD寬度,然後它工作正常,我

#data th, #data td { 
    border-bottom: 1px solid #808080; 
    border-right: 1px solid #808080; 
    padding: 3px; 
    width: 150px; <-- Try removing this 
} 
+0

仍然沒有差異。 –

+0

你在測試什麼瀏覽器?也仔細看了一下,所有的表格行標籤都沒有結束。 – TravJenkins

0

您forgott jQuery的CSS文件:

<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/smoothness/jquery-ui.min.css" rel="stylesheet" type="text/css" /> 

我已經犯了這個錯誤:)

+0

不管用。 –

+0

這是正確的 - 這需要添加到頁面。另外,它需要ID在桌面上。下面是它的一個小工具:http://jsfiddle.net/33NEE/ – TravJenkins

+0

爲我工作:http://jsbin.com/otecac/2/edit –