Page 1 of 1

Centering table in Author Mode

Posted: Thu Jun 06, 2024 11:01 am
by tmakita
My user wants to center tables in Author Mode.
I've tried following CSS but it seems not work.

Code: Select all

*[class~='topic/table'][outputclass~='center']{
    margin: auto;
}
Do you have any suggestions?
Regards,

Re: Centering table in Author Mode

Posted: Thu Jun 06, 2024 1:27 pm
by Radu
Hi,
Assuming your table has column widths which are fixed like this:

Code: Select all

<table frame="all" rowsep="1" colsep="1"
                id="table_ump_qnm_qbc" outputclass="center">
                <title>fds</title>
                <tgroup cols="2">
                    <colspec colname="c1" colnum="1" colwidth="75pt"/>
                    <colspec colname="c2" colnum="2" colwidth="75pt"/>
                    <thead>
                        <row>
                            <entry/>
                            <entry/>
                        </row>
                    </thead>
                    <tbody>
                        <row>
                            <entry/>
                            <entry/>
                        </row>
                    </tbody>
                </tgroup>
            </table>
something like this seems to work for me:

Code: Select all

*[class~='topic/table'][outputclass~='center']{
    margin: auto;
    width:10px;
}
It should work even without specifying that 10px width (which is not taken into account anyway as the colspecs are larger) but it does not work without specifying a width in the CSS.
Regards,
Radu

Re: Centering table in Author Mode

Posted: Thu Jun 06, 2024 2:18 pm
by tmakita
Thank you Radu!
It's a nice suggestion.
Regards,