Skip to main content
Inspiring
Sep 19, 2022 2:35 PM UTC
Answered

Best practice for creating the lines above add below the text for export to epub

I need to create these lines above and below a chapter title in ID. I can create a simple underline UNDERNEATH the text but what about above it? Once done corrdctly I have to export the doc as an epub and want to make sure there is good spacing.

 

James Gifford—NitroPress
Legend
Sep 19, 2022 4:56 PM UTC

Here is the css for that style as it is

p.Main-Title-Border {
border-color:#5780ca;
border-style:solid;
border-width:1px 0px 1px 0px;
color:#00aeef;
font-family:"Minion Pro", serif;
font-size:2.25em;
font-style:normal;
font-variant:normal;
font-weight:normal;
line-height:1.2;
margin-bottom:0;
margin-left:0;
margin-right:0;
margin-top:0;
orphans:1;
page-break-after:auto;
page-break-before:auto;
text-align:center;
text-decoration:none;
text-indent:0;
text-transform:none;
widows:1;
}
 
If I ADD the rules you posted the width of the line does not change
 
p.STYLENAME {
border-top: solid 2px black;
border-bottom: solid 2px black;
padding-top: 10px;
padding-bottom: 10px;
}

Ha.

 

Add the parameter "width: min-content;" to the CSS definition. This does not work in Kindle (my usual end point) but does work in my two primary test EPUB readers.

 

(EPUB is secondary for me, so if it doesn't work in Kindle, I tend to forget about it.)

 

And if you want some slight extension of the lines beyond the text, add small amounts of left and right padding.

 

—

16 replies

BobLevine
Community Expert
Community Expert
Sep 19, 2022 2:39 PM UTC

Assuming that's a single paragraph, use the rule above and the rule below in the paragraph style definition.

Translate
Inspiring
Sep 19, 2022 3:27 PM UTC

Added rules looks great but does NOT export to epub. I had an underline BEFORE adding the rules. I removed underline and added the two rules but it does not export to epub Reflowable

?????

Translate
James Gifford—NitroPress
Legend
Sep 19, 2022 4:05 PM UTC

Curious...why define it as a p with a class when you could use h1 since it's a chapter heading only?


Because everything is defined as p. by default unless you reassign it in the export menu. I doubt that's been done here. (It is a good idea, to impose HTML structure on the export, for accessiblity and other reasons. But keeping it simple here.)

 

—

Translate
Willi Adelberger
Community Expert
Community Expert
Sep 19, 2022 2:39 PM UTC

Some Possibilities in Paragraph Styles:

  • Paragraph Frame
  • Rulers abover and below
Translate