|
|
#1 |
|
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45
Karma: 972
Join Date: Jul 2011
Device: Kobo Aura One, Kobo Libra Colour
|
As a small publisher, I'm looking for a way to scale my epub title so that it fits e.g., 80% of the screen, regardless of window size.
vw I had used vw, and Google suggested clamp (e.g., below), but apparently that doesn't work for all e-readers Code:
h1 {
font-size: clamp(1.2rem, 4vw, 2.5rem);
}
I have tried a scaling container (e.g., below), but apparently that also doesn't work for all e-readers, and I got inconsistent results even in Sigil. Code:
<div class="title-container">
<h1 class="title-single-line">Title</h1>
</div>
.title-container {
width: 90%;
margin: 0 auto;
text-align: center;
}
.title-single-line {
white-space: nowrap;
font-size: 8vw%;
display: block;
}
Google also once suggested an svg container (below), but apparently there are issues. (Also, I know nothing about svg). Code:
<div style="width: 100%; max-width: 600px; margin: 0 auto;">
<svg viewBox="0 0 500 60" width="100%" height="100%" xmlns="http://w3.org">
<text x="50%" y="70%" font-family="sans-serif" font-size="40" font-weight="bold" fill="#333" text-anchor="middle">
Title
</text>
</svg>
</div>
Is there a foolproof, all-ereader method for scaling text to fit a window size? NB: I don't want to make the title an image. |
|
|
|
|
|
#2 |
|
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 83,495
Karma: 153646249
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Try %. All screens are 100%. Do not use rem or vw as they are not backwards compatible.
|
|
|
|
|
|
#3 |
|
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45
Karma: 972
Join Date: Jul 2011
Device: Kobo Aura One, Kobo Libra Colour
|
Thanks. Can you clarify what you mean? I assume [font-size: X%;] would set the title font to a percentage of the default or parent font, whereas what I'm looking for is % of the window size.
|
|
|
|
|
|
#4 |
|
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 83,495
Karma: 153646249
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Scaling the font size is a really bad idea. The problem is that if you are using a small screen such as a cell phone, the text could wrap where it would not otherwise.
Why do you want the title page to take up 80% of the screen? Why not just a regular title page? By suggesting using %, I was thinking of the space between elements. |
|
|
|
|
|
#5 |
|
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 51,958
Karma: 180003020
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
I've played with this a couple times. The main issue that I ran into is that many of the prettier techniques are not supported widely across multiple renderers.
The last solution I used which worked for a specific situation involved using a container-type inline-size and the font size set to 6cqw. I've attached a sample ePub using that technique. Edit: This method works on Sigil's preview and EpubJSReader plugin. The BibiReader and ReadiumReader plugins display the text but the resizing does not work. For calibre, the ebook-viewer and the ebook-editor's preview work happily. One item to remember is both Sigil and calibre are basically using a Chrome web browser to display the text. Last edited by DNSB; 05-19-2026 at 07:51 PM. Reason: Added comment about Sigil and calibre |
|
|
|
|
|
#6 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,933
Karma: 9600001
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
All ereaders? Epub2 and epub3 ones? The only way is to employ an image and give the image a widh of 80%. For example:
Code:
<h1 class="first" title="My title"><img class="title" alt="My title" src="../Images/Mytitle.svg"/></h1> Code:
.first {
text-align: center;
margin: 1em 0;
}
.title {
width: 80%;
}
Last edited by RbnJrg; 05-19-2026 at 08:59 PM. |
|
|
|
|
|
#7 |
|
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 51,958
Karma: 180003020
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
|
|
|
|
|
|
#8 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,933
Karma: 9600001
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
You're right, but since the OP used an SVG wrapper and the solution I posted uses an `<img>` tag with the text converted to a path, it might be a valid option for him. There's no other way to make a title occupy 80% of the viewport width, be immune to changes in text size by the user, and work under both EPUB2 and EPUB3.
|
|
|
|
|
|
#9 |
|
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 135
Karma: 2000
Join Date: Nov 2025
Device: none
|
I do not suggest anyone employ anything related to vertical position/scaling ie. vertical centering / % to height etc.
It can't even work properly in Sigil, let alone any random e-readers. Talking about this, I have a question: if someone use scrolling mode in reader apps, how is height % determined? Is it % to screen height or to the whole file length? Last edited by icearch; 05-20-2026 at 11:27 PM. |
|
|
|
|
|
#10 | |
|
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 83,495
Karma: 153646249
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
|
|
|
|
|
|
|
#11 | |||
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,933
Karma: 9600001
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
Quote:
Quote:
Code:
html, body {
height: 100%;
margin: 0;
}
body {
background: blue;
position: relative;
}
.vcenter {
width: 100%;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 2em;
font-weight: bold;
text-align: center;
}
Code:
<body> <div class="vcenter">This text is centered</div> </body> Change the font size (for example, to 5em)to watch how vertical-centering works. OTOH, the problems disappear under epub2 if other units of measurement are used instead of "%" (for example, "px"): In the above examplo I use "px" for font-size but is the same if you use "em". Also I used inline styling to have the xhtml code and the css in the same screen but is better to employ classes And remember, vertical centering is regarding the height of the containing block. Last edited by RbnJrg; 05-21-2026 at 12:31 PM. |
|||
|
|
|
|
|
#12 |
|
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 135
Karma: 2000
Join Date: Nov 2025
Device: none
|
I see, thanks for your explaination. I will try them later.
|
|
|
|
![]() |
| Tags |
| epub, scale, title |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Scalable maps | Berzelius | Sigil | 9 | 12-31-2015 09:44 AM |
| Which font works best in title? | Gregg Bell | Writers' Corner | 17 | 01-31-2015 01:05 AM |
| Glo Highlighting text only works for a while | RobertJSawyer | Kobo Reader | 9 | 02-01-2013 04:53 PM |
| Touch No good font size for a book (fonts aren't scalable enough) | jerrry94087 | Barnes & Noble NOOK | 6 | 06-12-2011 11:30 AM |
| Scalable SWF for Bookworm | ninni | ePub | 1 | 01-18-2010 11:33 AM |