Forum Samples, Tips and Tricks

Centering an image that already has a margin

Ben
Isn't really a Prince hack, but a CSS hack that I found useful... Normally graphics can be centered by applying a simple margin:auto to the tag. But for this excersize, I had a page content set to a specific width, and needed the imaged floated not only to the outside of this width, but beyond the regular margin (hence the margin-outside:-170pt). The way I got around this was to use the following css

display: block;
float: outside;
width: 170pt;
margin-outside:-170pt;
text-align: center;
color: #FFFFFF;
content: attr("print", url) "\A";


The color probably isn't necessary to specifically set. The space will be centered within that marginal space, brining the graphic along with it.