Page 1 of 1

Center image in PDF output by CSS

Posted: Wed Apr 04, 2018 12:48 pm
by anna_craneo
Hi,
I use CSS to format images. Here are my styles:

Code: Select all

/* ==================================================
*
* <fig>
*
* The fig element is a figure (sometimes called an
* "exhibit") with an optional title for a wide variety
* of content.
*/
*[class ~= "topic/fig"] {
display: block;

font-style: italic;
margin-left:auto;
margin-right:auto;

}
/*
* The figure titles are italic only in the stand-alone application.
*/
*[class ~= "topic/fig"] > *[class ~= "topic/title"] {
font-style: italic;
font-size: 12px;
text-align: center;
color: #4B4646;
}

/* Center the image within it's fig container */
*[class~="topic/fig"] > *[class~="topic/image"] {
text-align: center;

margin-left:auto;
margin-right:auto;
}
But in the output it seems to make no effect. Example:
Image

Re: Center image in PDF output by CSS

Posted: Thu Apr 05, 2018 2:57 pm
by Dan
Hello Anna,

Check the placement attribute is set to "break" on your images (others than the ones from the fig element) and use the following CSS snippet:

Code: Select all


/*
This centers the title text and the image if the image has the
placement attribute set to inline. The inline placement is the the default.
*/
*[class ~= "topic/fig"] {
text-align:center;
}

/* Other images, with break placement. */
*[class ~= "topic/image"][placement='break']{
display:block;
text-align:center;
}

/*
Scaled images are getting a computed width attribute, so we can use the auto margins.
Auto margins function only if the block they apply to has a width.
*/
*[class ~= "topic/image"][placement='break'][width] {
margin-left:auto;
margin-right:auto;
border: 2pt solid red;
}
If you still have problems, please use the technical contact form and send us a fragment from the topic.

Many regards,
Dan

Re: Center image in PDF output by CSS

Posted: Wed Apr 11, 2018 12:25 pm
by anna_craneo
But did not work for me.
I have sent an issue to tech support on Thursday (5th April), but no answer so far. :(

Re: Center image in PDF output by CSS

Posted: Wed Apr 11, 2018 12:45 pm
by Dan
Yes, there were some delays because of the Orthodox Easter holidays. I've already replied on the private email.

Regards,
Dan