Center image in PDF output by CSS

Questions about XML that are not covered by the other forums should go here.
anna_craneo
Posts: 33
Joined: Tue Feb 20, 2018 2:51 pm

Center image in PDF output by CSS

Post 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
Dan
Posts: 501
Joined: Mon Feb 03, 2003 10:56 am

Re: Center image in PDF output by CSS

Post 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
anna_craneo
Posts: 33
Joined: Tue Feb 20, 2018 2:51 pm

Re: Center image in PDF output by CSS

Post 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. :(
Dan
Posts: 501
Joined: Mon Feb 03, 2003 10:56 am

Re: Center image in PDF output by CSS

Post by Dan »

Yes, there were some delays because of the Orthodox Easter holidays. I've already replied on the private email.

Regards,
Dan
Post Reply