2016-07-19 1 views
0

Ich versuche, meinen Text in der Tabelle auszurichten. Es funktioniert jedoch nur für die td, aber nicht für th.Text-Align in CSS arbeiten für , aber nicht für <th>

HTML & CSS für die Tabelle, th, td:

table { 
 
    width: 100%; 
 
    border-collapse: separate; 
 
    text-align: center; 
 
} 
 
th, 
 
td { 
 
    border-bottom: 1px solid #ddd; 
 
    padding: 30px; 
 
    text-align: center; 
 
}
<table> 
 
    <tr> 
 
    <th><font size=6>Item name</font> 
 
    </th> 
 
    <th><font size=6>Brand</font> 
 
    </th> 
 
    <th><font size=6>Category</font> 
 
    </th> 
 
    <th><font size=6>Price</font> 
 
    </th> 
 
    <th><font size=6>Date of purchase</font> 
 
    </th> 
 
    </tr> 
 
    <tr> 
 
    <td><font size=4>{{ wish[4] }}</font> 
 
    </td> 
 
    <td><font size=4>{{ wish[6] }}</font> 
 
    </td> 
 
    <td><font size=4>{{ wish[5] }}</font> 
 
    </td> 
 
    <td><font size=4>{{ wish[7] }}</font> 
 
    </td> 
 
    <td><font size=4>{{ wish[3] }}</font> 
 
    </td> 
 
    </tr> 
 
</table>

+1

können Sie Ihren HTML-Code auch platzieren .. – vignesh

+1

können Sie Ihren vollständigen Code veröffentlichen. Ich habe versucht und es hat gut funktioniert –

+1

Scheint für mich zu arbeiten. http://jsbin.com/zexopo/edit?html,css,output –

Antwort

2

ich vermuten, dass Ihr th woanders überschrieben wird.

Sie können dies tun, obwohl ich es nicht empfehle.

th,td { 
    text-align: center !important; 
} 
1

Es scheint zu funktionieren. Irgendein anderer CSS-Code muss anderswo damit in Konflikt stehen.

Sie können !important nach Ihren Attributwerten verwenden. Es sollte gut funktionieren.

+0

danke, es hat funktioniert! – oreo

Verwandte Themen