我不是發生了什麼,但這裏是我的HTML;表中的水平中心單選按鈕
<tr id='javatbd158311X2059X38315A008' class='array2 answers-list radio-list'>
<td class="answer_cell_003 answer-item radio-item">
<label class="hide read" for="answer158311X2059X38315A008-3">Neither agree nor disagree</label>
<input class="radio" type="radio" name="158311X2059X38315A008" value="3" id="answer158311X2059X38315A008-3" title="Neither agree nor disagree" onclick="checkconditions(this.value, this.name, this.type)" />
</td>
</tr>
我想中央對齊單選按鈕,但只是停留在左側。到目前爲止,我嘗試過類似的東西;
table td .radio { text-align:center; margin-left:auto; margin-right:auto; border:1px solid red;}
table tr td { text-align:center; margin-left:auto; margin-right:auto; border:1px solid red;}
它會承認border
屬性。並顯示一個紅色的邊框,所以我知道它被正確地引用。
我在做什麼錯?
UPDATE;更多的代碼
table td .radio { border:1px solid red;display: block;margin:0 auto;}
table tr td { text-align:center; margin-left:auto; margin-right:auto; border:1px solid red;}
\t <table class="question subquestions-list questions-list " summary="An array with sub-question on each line. The answers are contained in the table header. ">
\t \t <colgroup class="col-responses">
\t \t <col class="col-answers" width="50%%" />
\t <col class="odd" width="10%" />
\t <col class="even" width="10%" />
\t <col class="odd" width="10%" />
\t <col class="even" width="10%" />
\t <col class="odd" width="10%" />
\t \t </colgroup>
\t \t <thead><tr class="dontread">
\t \t <td> </td>
\t \t <th>Strongly agree</th>
\t \t <th>Agree</th>
\t \t <th>Neither agree nor disagree</th>
\t \t <th>Disagree</th>
\t \t <th>Strongly disagree</th>
\t </tr></thead>
\t \t
\t <tbody>
\t
\t \t <tr id='javatbd158311X2059X38315A008' class='array2 answers-list radio-list'>
\t \t <th class="answertext">
\t a. One.<input type="hidden" name="java158311X2059X38315A008" id="java158311X2059X38315A008" value="" />
\t \t </th>
\t \t \t \t <td class="answer_cell_001 answer-item radio-item">
\t <label class="hide read" for="answer158311X2059X38315A008-1">Strongly agree</label>
\t \t <input class="radio" type="radio" name="158311X2059X38315A008" value="1" id="answer158311X2059X38315A008-1" title="Strongly agree" onclick="checkconditions(this.value, this.name, this.type)" />
\t \t </td>
\t \t \t \t <td class="answer_cell_002 answer-item radio-item">
\t <label class="hide read" for="answer158311X2059X38315A008-2">Agree</label>
\t \t <input class="radio" type="radio" name="158311X2059X38315A008" value="2" id="answer158311X2059X38315A008-2" title="Agree" onclick="checkconditions(this.value, this.name, this.type)" />
\t \t </td>
\t \t \t \t <td class="answer_cell_003 answer-item radio-item">
\t <label class="hide read" for="answer158311X2059X38315A008-3">Neither agree nor disagree</label>
\t \t <input class="radio" type="radio" name="158311X2059X38315A008" value="3" id="answer158311X2059X38315A008-3" title="Neither agree nor disagree" onclick="checkconditions(this.value, this.name, this.type)" />
\t \t </td>
\t \t \t \t <td class="answer_cell_004 answer-item radio-item">
\t <label class="hide read" for="answer158311X2059X38315A008-4">Disagree</label>
\t \t <input class="radio" type="radio" name="158311X2059X38315A008" value="4" id="answer158311X2059X38315A008-4" title="Disagree" onclick="checkconditions(this.value, this.name, this.type)" />
\t \t </td>
\t \t \t \t <td class="answer_cell_005 answer-item radio-item">
\t <label class="hide read" for="answer158311X2059X38315A008-5">Strongly disagree</label>
\t \t <input class="radio" type="radio" name="158311X2059X38315A008" value="5" id="answer158311X2059X38315A008-5" title="Strongly disagree" onclick="checkconditions(this.value, this.name, this.type)" />
\t \t </td>
\t </tr>
\t
\t
\t \t <tr id='javatbd158311X2059X38315A603' class='array1 answers-list radio-list'>
\t \t <th class="answertext">
\t b. Two.<input type="hidden" name="java158311X2059X38315A603" id="java158311X2059X38315A603" value="" />
\t \t </th>
\t \t \t \t <td class="answer_cell_001 answer-item radio-item">
\t <label class="hide read" for="answer158311X2059X38315A603-1">Strongly agree</label>
\t \t <input class="radio" type="radio" name="158311X2059X38315A603" value="1" id="answer158311X2059X38315A603-1" title="Strongly agree" onclick="checkconditions(this.value, this.name, this.type)" />
\t \t </td>
\t \t \t \t <td class="answer_cell_002 answer-item radio-item">
\t <label class="hide read" for="answer158311X2059X38315A603-2">Agree</label>
\t \t <input class="radio" type="radio" name="158311X2059X38315A603" value="2" id="answer158311X2059X38315A603-2" title="Agree" onclick="checkconditions(this.value, this.name, this.type)" />
\t \t </td>
\t \t \t \t <td class="answer_cell_003 answer-item radio-item">
\t <label class="hide read" for="answer158311X2059X38315A603-3">Neither agree nor disagree</label>
\t \t <input class="radio" type="radio" name="158311X2059X38315A603" value="3" id="answer158311X2059X38315A603-3" title="Neither agree nor disagree" onclick="checkconditions(this.value, this.name, this.type)" />
\t \t </td>
\t \t \t \t <td class="answer_cell_004 answer-item radio-item">
\t <label class="hide read" for="answer158311X2059X38315A603-4">Disagree</label>
\t \t <input class="radio" type="radio" name="158311X2059X38315A603" value="4" id="answer158311X2059X38315A603-4" title="Disagree" onclick="checkconditions(this.value, this.name, this.type)" />
\t \t </td>
\t \t \t \t <td class="answer_cell_005 answer-item radio-item">
\t <label class="hide read" for="answer158311X2059X38315A603-5">Strongly disagree</label>
\t \t <input class="radio" type="radio" name="158311X2059X38315A603" value="5" id="answer158311X2059X38315A603-5" title="Strongly disagree" onclick="checkconditions(this.value, this.name, this.type)" />
\t \t </td>
\t </tr>
\t </tbody>
\t </table>
在您的示例代碼,加入紅色邊框到兩個'.radio'和'表TR td'有點混亂。不同顏色的邊界可能會讓事情變得更加清晰。 –