![]() |
#1 |
Enthusiast
![]() Posts: 30
Karma: 10
Join Date: Apr 2025
Device: none
|
Hiding Other Answers in epub2
I am making a reflowable EPUB 2 book using Sigil. The book also has about 400 questions and 400 answers, divided into two parts: one part for the questions, and one part for the answers.
Each question has a link that goes to its answer, and each answer has a link that goes back to its question. I want to make sure that when a reader clicks on a link to an answer, they only see that one answer, not the other answers. One simple way is to put each answer in a separate HTML file, but KDP does not allow more than 300 HTML files. I also tried using page breaks, but they don’t work properly on all devices like Kobo. I know I can't use JavaScript because most eBook platforms don’t support it. So, I want to ask: Will this idea work? After each answer, I add this line in HTML: <p class="endline">===============</p> And in CSS: p.endline { font-weight: bold; text-align: center; margin-bottom: 100vh; } This puts a long space after each answer to push the next answer far down, so only one answer is seen at a time. What do you think? Will this be a good way to solve the problem? |
![]() |
![]() |
![]() |
#2 | |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,612
Karma: 145864263
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
|
|
![]() |
![]() |
![]() |
#3 |
Enthusiast
![]() Posts: 30
Karma: 10
Join Date: Apr 2025
Device: none
|
|
![]() |
![]() |
![]() |
#4 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,612
Karma: 145864263
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
|
![]() |
![]() |
![]() |
#5 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,345
Karma: 20171571
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
Have you used {page-break-after: always}?? Or any of its alternative forms...
Code:
<p class="answer">Answer to question #x</p>
.answer {
page-break-after: always;
break-after: always;
-moz-column-break-after: always;
-webkit-column-break-after: always;
*// whatever styling you want //*}
Code:
<div class="answer">
<p>Answer to question #x</p>
<p>more answer</p>
<p>even more answer.</p>
</div>
.answer {
page-break-after: always;
break-after: always;
-moz-column-break-after: always;
-webkit-column-break-after: always;
}
.answer p {*// whatever styling you want //*}
Last edited by Turtle91; Yesterday at 07:18 AM. |
![]() |
![]() |
![]() |
#6 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,345
Karma: 20171571
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
|
![]() |
![]() |
![]() |
#7 |
Enthusiast
![]() Posts: 38
Karma: 10
Join Date: May 2025
Device: iPad
|
I don't know whether this specific solution works with Kindle formats, so you would have to try.
This approach won't split the question-answer segment into two sections, but will show the answer directly under each question. It relies on a checkbox and its :checked pseudo selector to toggle the visibilty of the answer: HTML Code:
<div class="question"> <p>Is the sky blue?</p> <label for="checkbox-answer_1" class="toggle-answer"> Click here to show/hide the answer. </label> <!-- We have to place the checkbox outside the label element since otherwise targeting .answer wouldn't be possible. This requires an id to link the label to the checkbox. --> <input type="checkbox" id="checkbox-answer_1" class="checkbox-answer"/> <div class="answer"> <p>Yes, the sky is blue.</p> </div> </div> Code:
.question { padding: 0.1em 1em; background-color: #eee; } .answer { visibility: hidden; background-color: #ddd; } .toggle-answer { cursor: pointer; /* prevent accidentally selecting */ -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } /* hide the checkbox, not a must for functionality */ .checkbox-answer { position: absolute; top: -1000px; left: -6000px; width: 0; height: 0; opacity: 0; } .checkbox-answer:checked ~ .answer { visibility: visible; } |
![]() |
![]() |
![]() |
#8 | |
Enthusiast
![]() Posts: 30
Karma: 10
Join Date: Apr 2025
Device: none
|
Quote:
I already have tested these codes: page-break-after: always; break-after: always; They work in Kindle Previewer and ADE 2.0, but not in Kobo Desktop. Now I tried these: page-break-after: always; break-after: always; -moz-column-break-after: always; -webkit-column-break-after: always; But it's the same—they work in Kindle Previewer and ADE 2.0, but still not in Kobo Desktop. |
|
![]() |
![]() |
![]() |
#9 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,612
Karma: 145864263
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
|
![]() |
![]() |
![]() |
#10 | |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,612
Karma: 145864263
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
|
|
![]() |
![]() |
![]() |
#11 | |
Enthusiast
![]() Posts: 38
Karma: 10
Join Date: May 2025
Device: iPad
|
Quote:
Regarding the px to hide the checkbox, it doesn't matter which size the screen has, it's just a big value to place the checkbox way out of the viewport. Values of -100/-100 should work as well, as long as there is no relative parent along the way up to the body element. |
|
![]() |
![]() |
![]() |
#12 | |
Enthusiast
![]() Posts: 30
Karma: 10
Join Date: Apr 2025
Device: none
|
Quote:
I tested them on different apps. In Sigil, they work very well. In Kindle Previewer, the answer is hidden, but clicking does not show it. In ADE 2.0, the answer is already visible (it doesn't hide). In Kobo Desktop, the answer is hidden, but clicking does not show it. I wish these codes worked in all apps the same way they work in Sigil. Thanks again! |
|
![]() |
![]() |
![]() |
#13 | |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,612
Karma: 145864263
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
Code:
.toggle-answer { cursor: pointer; /* prevent accidentally selecting */ -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } /* hide the checkbox, not a must for functionality */ .checkbox-answer { position: absolute; top: -1000px; left: -6000px; width: 0; height: 0; opacity: 0; } |
|
![]() |
![]() |
![]() |
#14 | |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,345
Karma: 20171571
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
Quote:
It is ePub compatible if the renderer is ePub compliant. ePub renderers are required to ignore bad/non-supported css gracefully... If ePubcheck doesn't complain about it, neither should you. ![]() Do you happen to have a suggestion to make it work, rather than simply telling people it won't work?? |
|
![]() |
![]() |
![]() |
#15 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,724
Karma: 24031401
Join Date: Dec 2010
Device: Kindle PW2
|
Quote:
|
|
![]() |
![]() |
![]() |
Tags |
100vh, code, epub, margin, space |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
EPUB2 vs EPUB3 | langshipley | ePub | 4 | 01-13-2023 06:47 PM |
[Plugin] epub2 output | Doitsu | Plugins | 11 | 12-01-2021 04:17 PM |
Hiding endnotes after the last page of an epub2 | HHJT | ePub | 52 | 02-27-2018 08:09 PM |
epub3 to epub2 | AlanHK | Sigil | 11 | 08-09-2017 05:06 AM |
EPUB2 and the DOCTYPEgate | roger64 | ePub | 21 | 07-18-2014 07:49 PM |