CSS: Dynamic width based on text content
Post here questions and problems related to oXygen frameworks/document types.
-
- Posts: 9
- Joined: Mon May 10, 2021 10:55 am
CSS: Dynamic width based on text content
Is it possible to create a box inside oXygenXML with a dynamic width, based on the text content?
Does fit-content not work in oXygenXML?
I tried the following:
However, the width is still extended to the full width of the page, as shown on the image.
I have also tried with other elements, this does not seem to change the result.

Does fit-content not work in oXygenXML?
I tried the following:
Code: Select all
conbody{
background-color: #f0f0f0;
padding: 10px;
width: fit-content;
I have also tried with other elements, this does not seem to change the result.
-
- Posts: 9424
- Joined: Fri Jul 09, 2004 5:18 pm
Re: CSS: Dynamic width based on text content
Hi,
I'm afraid Oxygen's CSS support for rendering XML content in the Author mode does not support the "fit-content" value for "width":
https://www.oxygenxml.com/doc/versions/ ... pport.html
I'm afraid I do not have a good workaround for what you want (showing the background color just under the text without having it span the entire page width).
Regards,
Radu
I'm afraid Oxygen's CSS support for rendering XML content in the Author mode does not support the "fit-content" value for "width":
https://www.oxygenxml.com/doc/versions/ ... pport.html
I'm afraid I do not have a good workaround for what you want (showing the background color just under the text without having it span the entire page width).
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 9424
- Joined: Fri Jul 09, 2004 5:18 pm
Re: CSS: Dynamic width based on text content
Hi,
Looking at the supported properties table I linked above, both min-width and max-width seem to be supported. How are you using them?
Regards,
Radu
Looking at the supported properties table I linked above, both min-width and max-width seem to be supported. How are you using them?
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 9
- Joined: Mon May 10, 2021 10:55 am
Re: CSS: Dynamic width based on text content
Hi Radu,
I apologize, I did not take a good look at the supported properties table you had linked.
In this particular case I tried using it with a percentage so that it is a bit more flexible.
I also tried using min-width with other selectors which have a colored background, however, that did not work.
Using max-width in the same and width work perfectly fine though on the same selectors .
I apologize, I did not take a good look at the supported properties table you had linked.
In this particular case I tried using it with a percentage so that it is a bit more flexible.
Code: Select all
conbody{
background-color: #f0f0f0;
padding: 10px;
min-width: 50%;
}
Using max-width in the same and width work perfectly fine though on the same selectors .
-
- Posts: 9424
- Joined: Fri Jul 09, 2004 5:18 pm
Re: CSS: Dynamic width based on text content
Hi,
The min-width works when you also specify a width, otherwise the width is the entire page,
Maybe we can try for example to work with HTML and see how Oxygen and a web browser displays it, in this way if there are differences it means our CSS based rendering engine needs to be fixed:
both Oxygen and a web browser display the paragraph background on the entire page width. It's only after I set a " width:100px;" width that the min width starts to be taken into account.
Regards,
Radu
The min-width works when you also specify a width, otherwise the width is the entire page,
Maybe we can try for example to work with HTML and see how Oxygen and a web browser displays it, in this way if there are differences it means our CSS based rendering engine needs to be fixed:
Code: Select all
<html>
<head>
<title>dsadsa</title>
<style type="text/css">
p{
background-color: #f0f0f0;
padding: 10px;
min-width: 50%;
}
</style>
</head>
<body>
<p>paaram</p>
</body>
</html>
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 9
- Joined: Mon May 10, 2021 10:55 am
Re: CSS: Dynamic width based on text content
Hi Radu,
Thank you for your quick and informative response.
Your HTML example works on my end, however, while testing I noticed that when there is a break (space) in a text (writing a new word), it tends to write it on the following line. This means that the background will not extend.
If a longer word is written, then the background color will extended (as predicted).
I think this really a matter where fit-content would do what I am looking for, however, I understand that it is not supported yet.
Thank you
Thank you for your quick and informative response.
Your HTML example works on my end, however, while testing I noticed that when there is a break (space) in a text (writing a new word), it tends to write it on the following line. This means that the background will not extend.
If a longer word is written, then the background color will extended (as predicted).
I think this really a matter where fit-content would do what I am looking for, however, I understand that it is not supported yet.
Thank you
Return to “SDK-API, Frameworks - Document Types”
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