Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 11-12-2021, 02:04 AM   #1
Karellen
Wizard
Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.
 
Karellen's Avatar
 
Posts: 1,170
Karma: 4949904
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
Stacked boxes

The book I am currently reading has a decorative chapter heading as shown in the image. But the book creator simply scanned the chapter heading from the paper book and inserted the image into the book. There are 132 images. Also, when using a dark or sepia theme in the ebook, the white background in the jpg file is visible.

I created a CSS/HTML version of the same heading. But I think it is a bit messy and complex. Is there a neater way to do this?

My CSS code...
Spoiler:
PHP Code:
.box1 {
  
marginauto;
  
width130px;
  
height100px;
  
border1px solid gray;
  
background-colorgray;
  
box-sizingborder-box;
  
text-aligncenter;
}
.
box2 {
  
marginauto;
  
width130px;
  
height10px;
  
border1px solid gray;
  
background-colorgray;
  
box-sizingborder-box;
  
text-aligncenter;
}
.
box3 {
  
marginauto;
  
width420px;
  
height20px;
  
border1px solid black;
  
background-colorblack;
  
box-sizingborder-box;
  
text-aligncenter;
}
.
chapterno {
  
font-size3.0em;
  
font-familysans-serif;
  
colorwhite;
  
line-height0;
  
margin-bottom25px;
  
text-aligncenter;
}
.
chapterword {
  
font-weightbold;
  
font-size.8em;
  
font-familysans-serif;
  
colorwhite;
  
line-height0;
  
text-transformuppercase;
  
text-aligncenter;



My HTML code...
Spoiler:
PHP Code:
  <class="box2"></p>
  <
class="box3"><span class="chapterword">C&#8195;H A P T E R</span></p>
  
<div class="box1">  
  <
class="chapterno">99</p>
  </
div
Attached Thumbnails
Click image for larger version

Name:	chapterhead1.jpg
Views:	475
Size:	19.9 KB
ID:	190152  
Karellen is online now   Reply With Quote
Old 11-12-2021, 08:55 AM   #2
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,567
Karma: 7043711
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by Karellen View Post
The book I am currently reading has a decorative chapter heading as shown in the image. But the book creator simply scanned the chapter heading from the paper book and inserted the image into the book. There are 132 images. Also, when using a dark or sepia theme in the ebook, the white background in the jpg file is visible.

I created a CSS/HTML version of the same heading. But I think it is a bit messy and complex. Is there a neater way to do this?

My CSS code...
Spoiler:
PHP Code:
.box1 {
  
marginauto;
  
width130px;
  
height100px;
  
border1px solid gray;
  
background-colorgray;
  
box-sizingborder-box;
  
text-aligncenter;
}
.
box2 {
  
marginauto;
  
width130px;
  
height10px;
  
border1px solid gray;
  
background-colorgray;
  
box-sizingborder-box;
  
text-aligncenter;
}
.
box3 {
  
marginauto;
  
width420px;
  
height20px;
  
border1px solid black;
  
background-colorblack;
  
box-sizingborder-box;
  
text-aligncenter;
}
.
chapterno {
  
font-size3.0em;
  
font-familysans-serif;
  
colorwhite;
  
line-height0;
  
margin-bottom25px;
  
text-aligncenter;
}
.
chapterword {
  
font-weightbold;
  
font-size.8em;
  
font-familysans-serif;
  
colorwhite;
  
line-height0;
  
text-transformuppercase;
  
text-aligncenter;



My HTML code...
Spoiler:
PHP Code:
  <class="box2"></p>
  <
class="box3"><span class="chapterword">C&#8195;H A P T E R</span></p>
  
<div class="box1">  
  <
class="chapterno">99</p>
  </
div
There are easier ways to do what you want But before giving you a "solution", I need to know if you are working on epub2 or epub3?
RbnJrg is offline   Reply With Quote
Advert
Old 11-12-2021, 11:11 AM   #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,567
Karma: 7043711
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by RbnJrg View Post
There are easier ways to do what you want But before giving you a "solution", I need to know if you are working on epub2 or epub3?
Well, here you have a solution for epub2 (with epub3 the code is simpler yet). you can get the layout you are looking for with the following code:

1. In your .xhtml sheet, write this:

Code:
  <div class="center">
    <p class="greyBox">99</p>
  </div>

  <h1 class="👻">C* H* A* P* T* E* R</h1>

  <h2>ZOE ALAKIS</h2>
2. In your .css stylesheet write:

Code:
h1 {
   text-align: center;
   color: white;
   background: black;
   font-family: sans-serif;
   font-size: 1.1em;
   margin: -7em 0 0;
}

h2 {
   text-align: center;   
   font-size: 1.4em;
   margin: 0;
}

.center {
   position: relative;
   z-index: -1;
   height: 8.4em;
   text-align: center;
}

.greyBox {
   display: inline-block;
   width: 2.4em;
   height: 100%;
   line-height: 2.4em; 
   margin-top: 0;
   color: white;
   background: #999;
   font-size: 3.5em;
   font-weight: bold;
   font-family: sans-serif;
   text-align: center;
}

.👻 { /* Don't change the name of this class */
   margin-bottom: 5.6em; /* 7 - 1.4 = 5.6 */
}
To center the chapter number vertically, use the property "line-height". Its value must be equal to the height of the square. And since I employed as height 8.4em and the font-size is 3.5em, then the line-height is 8.4/3.5=2.4.
Don't change the name of the class ".👻" (it's a hack for ADE 2). Epubcheck will give you an error message but don't pay attention.
Here you can watch how it looks under ADE and webkit:

Click image for larger version

Name:	Image1.png
Views:	132
Size:	160.9 KB
ID:	190165 Click image for larger version

Name:	Image2.png
Views:	140
Size:	116.2 KB
ID:	190166 Click image for larger version

Name:	Image3.png
Views:	130
Size:	75.3 KB
ID:	190167 Click image for larger version

Name:	Image4.png
Views:	131
Size:	50.1 KB
ID:	190168 Click image for larger version

Name:	Image5.png
Views:	130
Size:	52.6 KB
ID:	190169 Click image for larger version

Name:	Image6.png
Views:	131
Size:	58.8 KB
ID:	190170

Below you can check the respective epub.

Regards.
Attached Files
File Type: epub Box Heading.epub (2.8 KB, 129 views)

Last edited by RbnJrg; 11-12-2021 at 11:20 AM.
RbnJrg is offline   Reply With Quote
Old 11-12-2021, 06:46 PM   #4
Karellen
Wizard
Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.
 
Karellen's Avatar
 
Posts: 1,170
Karma: 4949904
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
Hello @RbnJrg

Good call, I am using epub v2

Yes, that is much simpler. It took me a few minutes to pull it apart to see how it works, but I still don't understand the <h1 class="👻">. Why is it a h1 and not a <p> (as the auto TOC generator will capture the <h1>) and why a ghost emoji?

Thank you for the solution!!
Karellen is online now   Reply With Quote
Old 11-12-2021, 08:40 PM   #5
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,567
Karma: 7043711
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by Karellen View Post
Hello @RbnJrg

Good call, I am using epub v2

Yes, that is much simpler. It took me a few minutes to pull it apart to see how it works, but I still don't understand the <h1 class="👻">.
Classes whose names are emojis, they are not detected by ADE 2. So the margin-bottom for <h1> is not taken by ADE but webkit it is. ADE doesn't need that margin but webkit does. For that reason I employed that class.

Quote:
Why is it a h1 and not a <p> (as the auto TOC generator will capture the <h1>)?
You can exclude the <h1> tags for the TOC generator, that is not an issue. But if you feel that are more comfortable with a <p> tag instead of <h1>, no problem, is ok, use <p>.

By the way, your solution uses the property "margin: auto" and that is not supported by ADE for epub2 (is ok for webkit) and —still today— there are many ereaders based on Legacy ADE (RMSDK).

Quote:
Thank you for the solution!!
No problem!
RbnJrg is offline   Reply With Quote
Advert
Old 11-12-2021, 11:15 PM   #6
Karellen
Wizard
Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.
 
Karellen's Avatar
 
Posts: 1,170
Karma: 4949904
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
Quote:
Originally Posted by RbnJrg View Post
Classes whose names are emojis, they are not detected by ADE 2. So the margin-bottom for <h1> is not taken by ADE but webkit it is. ADE doesn't need that margin but webkit does. For that reason I employed that class.

You can exclude the <h1> tags for the TOC generator, that is not an issue. But if you feel that are more comfortable with a <p> tag instead of <h1>, no problem, is ok, use <p>.

By the way, your solution uses the property "margin: auto" and that is not supported by ADE for epub2 (is ok for webkit) and —still today— there are many ereaders based on Legacy ADE (RMSDK).

No problem!
Thanks for the explanations
Karellen is online now   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem resizing boxes giotti KOReader 5 11-05-2020 05:00 AM
Boxes instead of quotation marks testingfaze Conversion 2 12-03-2013 03:07 AM
just get black boxes jmugan Conversion 2 12-27-2011 10:13 AM
Boxes and boxes of books Elsi Lounge 14 07-22-2008 08:04 PM


All times are GMT -4. The time now is 07:42 PM.


MobileRead.com is a privately owned, operated and funded community.