View Single Post
Old 11-03-2018, 12:30 PM   #3
RbnJrg
Wizard
RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.
 
Posts: 1,801
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by Rapunzel View Post
...I’m still searching for a way to successfully center a block of left-aligned text with an unknown width in an epub.
According to the example you posted about the method you're currently using, actually you are using a width of 100% and with padding, you are adding some space on left and right margins. So, instead of using "padding" you can use the property "width" (i.e. 90%) and margins (left and right) of 5%.

Code:
/* Centered & Left-aligned text */
div.quote {
    margin: 2em 5%;
    width: 90%;
}

div.quote p {
    text-indent: 0;
    font-size: .85em;
    text-align: left;
    margin: 0;
}

div.quote p.sig {
    margin: 1em 0 0;
    text-align: right;
} /* For signature line */

Code:
  <div class="quote">
    <p>This is a paragraph of some sort. It can be of any length. The div will be centered on the page with the text left aligned within the div.</p>

    <p>You can adjust the width of the block (and margins) to give more/less space on either side.</p>

    <p class="sig">From the <em>Memoirs of Dion</em></p>
  </div>
Click image for larger version

Name:	Image1.png
Views:	262
Size:	116.8 KB
ID:	167419

Of course, the width of the text block plus left and right margins must be 100%

Regards
Rubén
RbnJrg is offline   Reply With Quote