Negative indents don't work?

115 Views Asked by At

I'm using CSS Paged Media to create a PDF. Most of my content is aligned normally, but I have a few paragraphs I want to give a negative indent: they should start 2.5 mm to the left of everything else.

This is my CSS so far:

h2 {
    font-family: Arial;
    background-color: #FF0000;
    font-size: 12pt;
    font-weight: bold;
    color: white;
    padding-left: 2.5mm;
    text-indent: -2.5mm;
}

This is the intended effect:

enter image description here

When I try the above in Antennahouse (6.5), the left edge of the red background block remains lined up with the left edge of the text "This service manual..."

So text-indent: -2.5mm; doesn't seem to be working as I expect. How can I get the effect I want?

1

There are 1 best solutions below

1
On BEST ANSWER

You were close. Drop the padding-left and use:

margin-left: -2.5mm;
text-indent: 2.5mm;

Or drop the text-indent and use:

margin-left: -2.5mm;
padding-left: 2.5mm;

The effect is the same in this case. It's the negative margin-left that moves the left edge of the block area for the h2 to the left.

The result shown in AH Formatter GUI (with area borders shown):

enter image description here