2012-05-26 19 views
0

我有一個應用程序,您可以訪問here。當你打開應用程序只需點擊加號按鈕,你會看到一個模態窗口出現一個搜索欄。如何保持表格100%寬?

現在請做這2個搜索:

搜索1:AAA

搜索2:AAE

你會看到,在AAE的搜索,該表去其全寬這是偉大的,但是如果你使用AAA Search,表格的寬度要小很多。

我希望表格的寬度始終保持固定爲100%(不希望它變小),但我不知道如何去做。

如何修改代碼以滿足要求?

下面是PHP代碼,其回聲表:

 $output = ""; 
$output .= " 
    <table border='1' id='resultbl'> 
     <tr> 
     <th id='questionth'>Question</th> 
     <th id='optiontypeth'>Option Type</th> 
     <th id='noofanswersth'>Number of <br/> Answers</th> 
     <th id='answerth'>Answer</th> 
     <th id='noofrepliesth'>Number of <br/> Replies</th> 
     <th id='noofmarksth'>Number of <br/> Marks</th> 
     </tr> 
"; 
     while ($questionrow = mysql_fetch_assoc($questionresult)) { 
$output .= " 
     <tr> 
     <td id='questiontd'>{$questionrow['QuestionContent']}</td> 
     <td id='optiontypetd'>{$questionrow['OptionType']}</td> 
     <td id='noofanswerstd'>{$questionrow['NoofAnswers']}</td> 
     <td id='answertd'>{$questionrow['Answer']}</td> 
     <td id='noofrepliestd'>{$questionrow['ReplyType']}</td> 
     <td id='noofmarkstd'>{$questionrow['QuestionMarks']}</td> 
     </tr>"; 
     } 
     $output .= "  </table>"; 

     echo $output; 

以下是完整的CSS代碼:埃維列標題和行對準中心,並且具有一個最小和最大寬度和它自身具有的表最小和最大寬度爲100%:

#questionth{ 
    min-width:35%; 
    max-width:35%; 
    text-align:center; 
} 

#optiontypeth{ 
    min-width:15%; 
    max-width:15%; 
    text-align:center; 
} 

#noofanswersth{ 
    min-width:10%; 
    max-width:10%; 
    text-align:center; 
} 

#answerth{ 
    min-width:20%; 
    max-width:20%; 
    text-align:center; 
} 

#noofrepliesth{ 
    min-width:10%; 
    max-width:10%;  
    text-align:center; 
} 

#noofmarksth{ 
    min-width:10%; 
    max-width:10%; 
    text-align:center; 
} 

#questiontd{ 
    min-width:35%; 
    max-width:35%;  
    text-align:center; 
} 

#optiontypetd{ 
    min-width:15%; 
    max-width:15%; 
    text-align:center; 
} 

#noofanswerstd{ 
    min-width:10%; 
    max-width:10%; 
    text-align:center; 
} 

#answertd{ 
    min-width:20%; 
    max-width:20%; 
    text-align:center; 
} 

#noofrepliestd{ 
    min-width:10%; 
    max-width:10%;  
    text-align:center; 
} 

#noofmarkstd{ 
    min-width:10%; 
    max-width:10%; 
    text-align:center; 
} 

#resulttbl{ 
    min-width:100%; 
    max-width:100%; 
} 

回答

4

請注意,您的CSS指的是#resulttbl。你的腳本正在輸出一個ID爲resultbl的表格,所以100%的寬度不適用於它。

+0

我是一個白癡,花了30分鐘,並沒有意識到拼寫錯誤。 OMG,歡呼:) – user1394925

1

爲什麼這麼複雜?只需要聲明的寬度和留在這一點:

#resulttbl{ 
    width:100%; 
} 

如果由於某種原因,不能正常工作,請嘗試使用!important。如果這確實起作用,那麼另一條規則就是優先於當前的規則。

#resulttbl{ 
    width:100% !important; 
} 

更新

超是正確的。我的回答在這一點上真的只是一個好建議。

1

如何使您的表格寬度= 100%?

相關問題