![]() |
#1 |
Junior Member
![]() Posts: 5
Karma: 10
Join Date: Oct 2020
Device: Kobo
|
How To Get H1 Chapter Titles To Show Like This?
EXAMPLE: https://imgur.com/uVySKKY
Hi everyone, I am using Jutoh Plus to create my book and I would like my Chapter Headings to look like the one above. Jutoh Plus allows near complete control over HTML and CSS so I am wondering if I can add a bit of CSS code to H1 section to get them to look like this? Can anyone help please? It will be much appreciated. ![]() |
![]() |
![]() |
![]() |
#2 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,663
Karma: 8566337
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
In your .xhtml file write the following: Code:
<h1 class="MyHeading">CHAPTER 1</h1> Code:
.MyHeading { width: 50%; /* or the width you wish */ margin-left: 25%; /* this must be according to the previous width */ margin-right: 25%; margin-bottom: 2em; /* or whatever you like */ color: white; background: lightblue; font-family: sans-serif; font-size: 1.1em; text-align: center; } Regards Ruben |
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Junior Member
![]() Posts: 5
Karma: 10
Join Date: Oct 2020
Device: Kobo
|
Hi Ruben,
It worked brilliantly. I did change the colour and font size a bit but now my epub is really looking perfect. Many, many thanks. ![]() |
![]() |
![]() |
![]() |
#4 |
Running with scissors
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,584
Karma: 14328510
Join Date: Nov 2019
Device: none
|
I suspect that the width, margin-left, and margin-right are not what they want; typically what's wanted is for the green box to automatically size itself to the size of the text (with a bit of space/padding/margin on the sides).
I vaguely recall banging my head against this a long time ago and never found a solution. Last edited by hobnail; 10-10-2020 at 08:22 PM. |
![]() |
![]() |
![]() |
#5 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,251
Karma: 16539642
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
|
Quote:
Code:
<h1 class="heading"><span class="decor">CHAPTER 1</span></h1> <h1 class="heading"><span class="decor">Chapter One Hundred and Fifty-Two</span></h1> Code:
.heading { font-family: sans-serif; font-size: 1.1em; margin: 3em 0; text-align: center; text-indent:0;} .decor { background: teal; color: white; padding: 0.5em 1em; } |
|
![]() |
![]() |
Advert | |
|
![]() |
#6 | |
Bookmaker & Cat Slave
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,503
Karma: 158448243
Join Date: Apr 2010
Location: Phoenix, AZ
Device: K2, iPad, KFire, PPW, Voyage, NookColor. 2 Droid, Oasis, Boox Note2
|
Quote:
Hitch |
|
![]() |
![]() |
![]() |
#7 |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,939
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
I never figured out how to make the box automatically fit the text.
You make a box (with or without Borders): Space the contents away from the edge with padding. Colors to taste AFAIK Outside Margins are the only way to contain a box size |
![]() |
![]() |
![]() |
#8 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,663
Karma: 8566337
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
1. In your .xhtml file: Code:
<div class="heading"> <h1 class="block">CHAPTER 1</h1> </div> Code:
.heading { text-align: center; } h1 { display: inline; font-size: 1.1em; font-family: sans-serif; margin: 1em auto; } .block { display: inline-block; background: teal; color: white; padding: 0.25em 1em; } ![]() I attach the respective epub so you can check everything. Last edited by RbnJrg; 10-11-2020 at 10:56 AM. |
|
![]() |
![]() |
![]() |
#9 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,663
Karma: 8566337
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
If you want the solution to work everywhere (that is, also in ADE), that's correct. However, if you can use the properties "margin-left: auto" and "margin-right: auto" (not supported by ADE in epub2), then by using properties "display: inline" and "display: inline-block", is possible to contain a box size without employing outside margins. See my previous post.
Last edited by RbnJrg; 10-11-2020 at 10:58 AM. |
![]() |
![]() |
![]() |
#10 | |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,398
Karma: 145491800
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
[QUOTE=RbnJrg;4045768]I posted my solution in order that it works everywhere. What you want, it can be achieved with the following code:
1. In your .xhtml file: Code:
<div class="heading"> <h1 class="block">CHAPTER 1</h1> </div> Code:
<h1 class="chapter">CHAPTER 1</h1> Quote:
Code:
.chapter { font-size: large; font-weight: bold; font-family: sans-serif; margin-top: 1em; margin-bottom: 1em; } |
|
![]() |
![]() |
![]() |
#11 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,663
Karma: 8566337
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
You wrote what you wrote because you didn't understand my code. Moreover, you didn't read what the OP asked. |
|
![]() |
![]() |
![]() |
#12 | |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,939
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
![]() ![]() |
|
![]() |
![]() |
![]() |
#13 |
Bookmaker & Cat Slave
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,503
Karma: 158448243
Join Date: Apr 2010
Location: Phoenix, AZ
Device: K2, iPad, KFire, PPW, Voyage, NookColor. 2 Droid, Oasis, Boox Note2
|
|
![]() |
![]() |
![]() |
#14 | |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,398
Karma: 145491800
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
|
|
![]() |
![]() |
![]() |
#15 |
Junior Member
![]() Posts: 5
Karma: 10
Join Date: Oct 2020
Device: Kobo
|
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Chapter #s or Chapter Titles? | bmcox | Writers' Corner | 33 | 02-01-2013 07:03 AM |
Show total pages of a chapter | Silvia_lollipop | Kindle Fire | 9 | 01-23-2013 04:13 PM |
Ebook chapter titles: with or without chapter number? | amoroso | Writers' Corner | 16 | 06-14-2011 06:35 AM |
PRS-350 Breaks after Chapter Titles | Rand Brittain | Sony Reader | 2 | 10-25-2010 12:53 PM |