View Single Post
Old 07-01-2010, 06:35 AM   #171
charleski
Wizard
charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.charleski ought to be getting tired of karma fortunes by now.
 
Posts: 1,181
Karma: 539735
Join Date: Sep 2009
Device: PRS-505
Unfortunately, the way you specify margins doesn't actually work as people might expect.

Margins specified in the body element will apply to the entire flow rather than to individual pages within that flow, so code such as
Code:
body{margin-left:5%;margin-right:5%;margin-top:5%;margin-bottom:5%}
will produce a 5% margin at the top of the first page in the flow and a 5% margin at the bottom of the final page in the flow, but no top and bottom margins on individual pages within the flow.

What you want to do instead is this:
Code:
@page {
    margin-top: 12pt;
    margin-bottom: 1pt
}
body {
    margin-left: 5%;
    margin-right: 5%
}
Notice that I used points instead of % for the top and bottom margins - unfortunately ADE's handling of the @page rule is slightly bizarre. If you use % here then ADE will translate it internally into some distance that does not change with changes in the height of the display port*. A margin-top of 100% becomes a margin of roughly 75pts, and a margin-top of 5% is roughly the same as a margin of 4pts (i.e. far too small). In this case it is far safer to specify the margins in points, which should produce a consistent result across reading systems.

The actual size of the bottom margin on a page is governed by the reader's line-fitting algorithm, so I generally just use a very small value there to prevent text from colliding with the bottom of the viewport, which effectively produces a bottom margin a little less than one line-height on the page. It would be a good idea to provide separate inputs for the top and bottom margins so that users can control this as they wish.

*In contrast, left and right margins specified using % in the body do scale properly with viewport changes.

Last edited by charleski; 07-01-2010 at 06:43 AM.
charleski is offline   Reply With Quote