Center image in PDF output by CSS
Questions about XML that are not covered by the other forums should go here.
-
- 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:
But in the output it seems to make no effect. Example:

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;
}

-
- Posts: 501
- Joined: Mon Feb 03, 2003 10:56 am
Re: Center image in PDF output by CSS
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:
If you still have problems, please use the technical contact form and send us a fragment from the topic.
Many regards,
Dan
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;
}
Many regards,
Dan
-
- 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.
I have sent an issue to tech support on Thursday (5th April), but no answer so far.

Return to “General XML Questions”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service