In the following code, I need to left justify the text in the first two columns and right justify the text in the last 4 columns with the exception of the table headers. Can't seem to figure it out and when I look for answers online I can't find anything on how to justify text within the cell of a table or specifically texts of just two columns. Would appreciate any help. Thanks
Use the nth-child
if you wanna specify exactly td
which you wanna set style. Take a look below. (Paste this code at the very bottom)
tr td:nth-child(3), tr td:nth-child(4), tr td:nth-child(5), tr td:nth-child(6) {
text-align: right;
}
th {
text-align: center;
}
If you don't want to use a class, you can add the following style
td + td + td {
text-align: right;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.