html - Specifying the width and text alignment of a column -


Is it possible to specify the width of the table column in percentages using CSS? Is it possible to specify the text alignment of a specific column as well?

For example, I have a table with 3 columns. I would like to say

  col1.width = 20% col2.width = 40% col3.width = 40% col1.text-align = left; Col2.text- align = right; Col3.text-align = center; Regarding the first question: make the sections that you send to each     

Umn Rather simple

The alignment of the text is a bit more difficult, because you can only specify as a whole. In this case, a solution would be to use the nth-child pseudo-class, but it is a CSS 3 feature that does not work in an existing version of Internet Explorer. As a proposal, you can use columns related to style in the + combination. This is a CSS 2.1 feature.

  & lt ;! DOCTYPE html & gt; & Lt; Top & gt; & Lt; Meta charset = UTF-8 & gt; & Lt; Title & gt; Column styling & lt; / Title & gt; & Lt; Style & gt; Table {table-layout: fixed; Width: 1000 pixels; }. First column {width: 20%; Background: #ccc; }. Other columns {width: 40%; Background: # aaa; } Td {text-align: left} td + td {text-align: right} td + td + td {text-align: center} & lt; / Style & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Table & gt; & Lt; Col class = "firstColumn" & gt; & Lt; Col class = "other column" & gt; & Lt; Col class = "other column" & gt; & Lt; TR & gt; & Lt; TD & gt; Bla & lt; / TD & gt; & Lt; TD & gt; Bla & lt; / TD & gt; & Lt; TD & gt; Bla & lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; Bla & lt; / TD & gt; & Lt; TD & gt; Bla & lt; / TD & gt; & Lt; TD & gt; Bla & lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; Bla & lt; / TD & gt; & Lt; TD & gt; Bla & lt; / TD & gt; & Lt; TD & gt; Bla & lt; / TD & gt; & Lt; / TR & gt; & Lt; / Table & gt; & Lt; / Body & gt; & Lt; / Html & gt;  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -