![]() |
#1 |
Junior Member
![]() Posts: 6
Karma: 10
Join Date: Oct 2023
Device: kobo clara hd
|
second column with notes in epub
I'm trying to put together an epub of a verse novel, and its in sort of a two column layout where the main text is on the left and some stanzas have a little explainer in a second column to the right. I would like it to be readable on smaller screens such that the explainers appear on the right if the screen is large enough, and otherwise appears below the stanza its' attached to, like in the attached pictures. i've seen books in the wild that use tables for plays but they always keep both columns and just shrink them when the screen gets smaller rather than moving one column below the other. looking around online it seems like media querries might work but i can't find any examples to copy.
|
![]() |
![]() |
![]() |
#2 |
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 44,805
Karma: 168802811
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
For some realworld examples, pick up an ebook that was formatted with Vellum. The media stylesheet is a mass of media queries, quite a few of which are related to differences in screen sizes. I've attached one example to this message. This is from an ePub so the amzn-kf8 and amzn-mobi queries were not included.
One issue with using this is that you will find divs multiplying like happy rabbits. |
![]() |
![]() |
![]() |
#3 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,641
Karma: 8566337
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
1. In your .css stylesheet: Code:
.container { display: grid; grid-template-columns: repeat(auto-fill, minmax(max(100px, 40vw), 1fr)); gap: 5px; justify-content: space-evenly; } .item { box-sizing: border-box; border: 1px solid blue; /* you can delete this if you wish */ text-align: center; /* change the alignment as you wish */ } Code:
<div class="container"> <div class="item">item-a</div> <div class="item">item-b</div> </div> Last edited by RbnJrg; Yesterday at 06:45 PM. |
|
![]() |
![]() |
![]() |
#4 | |
Junior Member
![]() Posts: 6
Karma: 10
Join Date: Oct 2023
Device: kobo clara hd
|
Quote:
tried it. in sigil it shows 2 columns and they stay as 2 columns when i shrink the preview window. in koreader they become rows no matter how wide the window is. |
|
![]() |
![]() |
![]() |
#5 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,641
Karma: 8566337
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
KOReader is an epub2 ereader and it doesn't support grid. This is only for epub3 ereaders. By chance, did you link the stylesheet to your .xhtml file? Last edited by RbnJrg; Yesterday at 10:22 PM. |
|
![]() |
![]() |
![]() |
#6 | |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,124
Karma: 144284184
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
Last edited by JSWolf; Yesterday at 08:27 PM. |
|
![]() |
![]() |
![]() |
#7 | |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,312
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:
media queries simply tell you what the size of the screen is (among other things)... - if the media meets a particular requirement it runs particular css. If it doesn't, it doesn't. Use css cascading/priority rules to determine what css takes priority. supports queries tells you whether a device supports a particular css - if the device supports a particular css it runs it. If it doesn't, it either doesn't do anything, or it runs alternate css. Use css cascading/priority rules to determine what css takes priority. javascript runs a script on devices that support js...it doesn't on devices that don't. Use combinations of all of the above, with fallback coding. If the above doesn't work it will fallback to to previous css. |
|
![]() |
![]() |
![]() |
#8 | |
Junior Member
![]() Posts: 6
Karma: 10
Join Date: Oct 2023
Device: kobo clara hd
|
Quote:
also i guess since koreader is an epub2 reader (i thought its worked with any epub3 features ive come across but either i was mistaken or its just a subset of epub3) and the 2nd box displayed under the 1st its good and i dont need to dive into media querries. |
|
![]() |
![]() |
![]() |
#9 | ||
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,641
Karma: 8566337
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
Quote:
1. In your .xhtml file write: Code:
<div class="container"> <div class="mainColumn">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ac tellus nunc. Phasellus imperdiet leo metus, et gravida lacus. Donec metus ligula, elementum at pellentesque pellentesque, suscipit ac nunc. Etiam lobortis, massa ac aliquam auctor, augue nisl sagittis urna, at dapibus tellus erat ullamcorper ligula. Praesent orci dui, pulvinar id convallis a, faucibus non mauris. Donec tellus augue, tempus sed facilisis sed, fringilla quis leo. Mauris vulputate, leo ac facilisis vulputate, enim orci interdum augue, in blandit quam turpis quis dui.</div> <div class="secondColumn">Donec tellus augue, tempus sed facilisis sed, fringilla quis leo.</div> </div> Code:
* { box-sizing: border-box; } .container { display: grid; grid-template-columns: 1fr; /* by default, one column */ gap: 10px; } .mainColumn { text-align: left; } .secondColumn { text-align: left; font-size: 0.9em; font-weight: 600; padding-left: 16px; } /* Media query for wider screens */ @media (min-width: 300px) { /* Change to the width of your wishes */ .container { grid-template-columns: 2fr 1fr; /* When the screen is wider than 300px, 2 cols */ } } But also you can have the same output by mean of flex-box. The code is a bit more complex: 1. In your .xhtml file: Code:
<div class="container"> <div class="mainColumn">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla ac tellus nunc. Phasellus imperdiet leo metus, et gravida lacus. Donec metus ligula, elementum at pellentesque pellentesque, suscipit ac nunc. Etiam lobortis, massa ac aliquam auctor, augue nisl sagittis urna, at dapibus tellus erat ullamcorper ligula. Praesent orci dui, pulvinar id convallis a, faucibus non mauris. Donec tellus augue, tempus sed facilisis sed, fringilla quis leo. Mauris vulputate, leo ac facilisis vulputate, enim orci interdum augue, in blandit quam turpis quis dui.</div> <div class="secondColumn">Donec tellus augue, tempus sed facilisis sed, fringilla quis leo.</div> </div> 2. In your .css stylesheet: Code:
* { box-sizing: border-box; } .container { display: flex; flex-wrap: wrap; } .mainColumn { flex: 70%; text-align: left; padding-bottom: 10px; } .secondColumn { flex: 30%; text-align: left; font-size: 0.9em; font-weight: 600; padding-left: 16px; } @media (max-width: 300px) { /* Change the width you want here */ .mainColumn, .secondColumn { flex: 100%; } } Below I attach an epub with the complete solution so you can understand better the code. OF COURSE, THIS IS ONLY FOR EPUB3, it won't work under epub2. Last edited by RbnJrg; Today at 09:32 AM. |
||
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to create column with number of notes in epub and create APA/MLA bibliographies? | retval | Library Management | 1 | 01-26-2024 09:23 PM |
Forma Why some notes are popup notes, some are jumping notes in Kobo Forma | codychan | Kobo Reader | 11 | 11-22-2022 02:25 PM |
EPUB 3 multi column text reading order across pages for epub | laksathish | ePub | 13 | 11-13-2018 05:18 AM |
Single column ePUB becomes 2 column when converted to Kindle (mobi) | rmcape | Conversion | 0 | 09-21-2013 12:52 PM |
Notes and Links in ePub | Pablo | ePub | 2 | 09-13-2009 08:04 AM |