Michael Santy wrote:
> In my application I would like to display tables centered horizontally
> in the page. As I understand it, I should just be able to add a
> "text-align: center;" declaration to the table block element. However,
> this directive appears to be ignored when I add it to my stylesheet.
>
> Just in case I was doing something wrong in my configuration, I tried to
> center the tables in the Docbook configuration with the same approach,
> changing:
>
> table,
> informaltable {
> display: block;
> margin: 1.33ex 0;
> }
>
> to:
>
> table,
> informaltable {
> display: block;
> margin: 1.33ex 0;
> text-align: center;
> }
>
> in the "addon/config/docbook/css/table.imp" CSS stylesheet. The tables
> are still not centering when loading the "demos/docbook-table.xml" file.
> Does anyone have any suggestions on what I'm doing wrong? Does the
> table rendering code ignore the text-align attribute by design?
>
Centering a table (or any other block) may be achieved by using:
---
margin-left: auto;
margin-right: auto;
---
and not:
---
text-align: center;
---
This would give for the above example:
---
table,
informaltable {
display: block;
margin-top: 1.33ex;
margin-bottom: 1.33ex;
margin-left: auto;
margin-right: auto;
}
---
However, in the case of tables you'll not see much differences because
XXE always makes tables as wide as possible in order to make it easy
typing text in the table cells.