View Single Post
Old 04-04-2011, 04:12 PM   #19
DreamWriter
Books are brain food.
DreamWriter ought to be getting tired of karma fortunes by now.DreamWriter ought to be getting tired of karma fortunes by now.DreamWriter ought to be getting tired of karma fortunes by now.DreamWriter ought to be getting tired of karma fortunes by now.DreamWriter ought to be getting tired of karma fortunes by now.DreamWriter ought to be getting tired of karma fortunes by now.DreamWriter ought to be getting tired of karma fortunes by now.DreamWriter ought to be getting tired of karma fortunes by now.DreamWriter ought to be getting tired of karma fortunes by now.DreamWriter ought to be getting tired of karma fortunes by now.DreamWriter ought to be getting tired of karma fortunes by now.
 
DreamWriter's Avatar
 
Posts: 2,950
Karma: 4836916
Join Date: Nov 2010
Location: U.S.
Device: Paperwhite · Fire HD6/HD8/HD10 · Galaxy Tab A7
Okay, I think I found a solution! I'm not sure why it works, but it does for me.

I did numerous experiments, with various combinations of coding. First, I used KindleGen to create the .mobi from the original HTML. The same problem with the chapters was there, so it isn't something peculiar only to Mobipocket Creator.

Now, I don't know if I can explain this clearly enough, but I'll try. I am not an expert in either HTML or CSS. I know enough to get by, but I'm sure that things are not "technically" correct.

My chapters are not wrapped within any <div> tags. I don't know if that would change anything. I have an external CSS file, but you could include the CSS within the HTML.

This is what worked for me at the beginning of each chapter:

HTML code:
Code:
<mbp:pagebreak />
<a name="Chapter1" /><h4 class="CHAPTERTITLE">Chapter 1</h4>
CSS code that is called by the H4 class from the HTML above:
Code:
h4.CHAPTERTITLE
	{page-break-before:always;
	page-break-after:avoid;
	margin-top:35pt;
	margin-bottom:0pt;
	margin-left:0pt;
	margin-right:0pt;
	text-align:center;
	text-indent:0pt;
	font-weight:bold;}
What makes it work is having BOTH the
Code:
<mbp:pagebreak />
before the beginning of each chapter AND the
Code:
page-break-before:always;
code in h4.CHAPTERTITLE CSS. One or the other alone did not work for me!

Now, when I use the 5-way or TOC to move to a chapter and then page-back/page-forward using the button on the side of the Kindle, the chapter title stays in the correct location on the page. (Note that it may move when you first open the file and try that. That's because the book name and battery icon are taking up space at the top until you page forward/back. When that top indicator line disappears, then all the chapters are where they should be.)

I hope that makes some sense! I'd be interested to know if this works for you too!

Last edited by DreamWriter; 01-20-2014 at 10:43 PM.
DreamWriter is offline   Reply With Quote