How to set margin-left without it being inherited by child elements?

Arne Evertsson picture Arne Evertsson · Jun 27, 2012 · Viewed 10k times · Source

I need to set the margin-left and margin-right of all contents within the page header (xsl-region-before). I've tried to add the attribute to a <fo:block> that in turn holds all the header contents. However the margin gets inherited by child blocks which is not what I want.

Is there a way to set the margin without it being inherited?

Answer

Arne Evertsson picture Arne Evertsson · Jul 2, 2012

I found a workaround: Setting the margin to a negative number in the inner block:

<fo:block margin-left="10mm" margin-right="10mm">
    <fo:table>
        <fo:table-column column-width="100%" />
        <fo:table-body>
            <fo:table-row>
                <fo:table-cell text-align="left">
                    <fo:block margin-left="-10mm" margin-right="-10mm">
                        Some text
                    </fo:block>
                </fo:table-cell>
            </fo:table-row>
        </fo:table-body>
    </fo:table>
</fo:block>