![]() |
#1 |
Browser
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 745
Karma: 578294
Join Date: Apr 2010
Location: Australia
Device: Kobo Touch, Kobo Aura HD
|
Background colour in place of text boxes
I understand in principle how to use text boxes and background colours. I don't want to use text boxes in an epub, since I want the text still to be able to flow, but I'd like to emulate the look to some degree.
So: is there any way to have the background colour stretch margin to margin, even though the text in front of it is indented by, say, 1 em on both sides? Also, to have the colour start maybe a line before the para text, without having to use clunky approaches like empty paragraphs? I assume this would require making the colour a separate element from the paragraph, rather than a property of the para itself, but I don't know who to do that. Thanks for any help. |
![]() |
![]() |
![]() |
#2 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,768
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
You can get that effect by giving the property "background: yellow" (or the color you want) to the body tag. Write the following in your css stylesheet: Code:
body { background: yellow; margin: 0 25px; } Regards Rubén |
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Browser
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 745
Karma: 578294
Join Date: Apr 2010
Location: Australia
Device: Kobo Touch, Kobo Aura HD
|
Thanks for the reply.
Something like that, yes, but applied to specific paragraphs -- like text boxes in print media -- rather than the whole document. |
![]() |
![]() |
![]() |
#4 | |
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 21,725
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
Quote:
Suggested reading. Pablo's tutorial ==>> https://wiki.mobileread.com/wiki/EPub_Tutorial Last edited by BetterRed; 05-07-2016 at 10:05 PM. |
|
![]() |
![]() |
![]() |
#5 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,821
Karma: 19162882
Join Date: Nov 2012
Location: Te Riu-a-Māui
Device: Kobo Glo
|
Add padding to make the background colour extend beyond the original object itself. e.g. the following displays the enclosed paragraphs in a blue box that extends 1em beyond the paragraphs and has an extra 0.5em of transparent margin top and bottom:
Code:
<div style="background-color:blue; padding:1em; margin:0.5em 0;"> <p> ... </p> <p> ... </p> </div> |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
mostly an observer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,519
Karma: 987654
Join Date: Dec 2012
Device: Kindle
|
That's nice stuff, thanks all! I can see the possibilities in using a gray background for something that in a print edition would be in a box.
|
![]() |
![]() |
![]() |
#7 |
temp. out of service
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,815
Karma: 24285242
Join Date: May 2010
Location: Duisburg (DE)
Device: PB 623
|
|
![]() |
![]() |
![]() |
#8 |
eBook Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 85,544
Karma: 93383099
Join Date: Nov 2006
Location: UK
Device: Kindle Oasis 2, iPad Pro 10.5", iPhone 6
|
You could also do it using a table.
|
![]() |
![]() |
![]() |
#9 |
Browser
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 745
Karma: 578294
Join Date: Apr 2010
Location: Australia
Device: Kobo Touch, Kobo Aura HD
|
Thanks all for your help with this.
GeoffR, what you suggested produced precisely the result I was looking for, so that's what I did. The missing piece for me was padding, which hadn't occurred to me. (Duh.) Though in other circumstances I can see tables could be a great way to go as well. |
![]() |
![]() |
![]() |
#10 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,756
Karma: 145864619
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
The problem with a background color is that on eInk it might be hard to read the text.
|
![]() |
![]() |
![]() |
#11 |
Browser
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 745
Karma: 578294
Join Date: Apr 2010
Location: Australia
Device: Kobo Touch, Kobo Aura HD
|
Yes, I've noticed that, but bolding the text and keeping the background very pale to increase the contrast seems to achieve the desired effect, if I choose a fairly open typeface.
|
![]() |
![]() |
![]() |
#12 | ||
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,306
Karma: 13057279
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
Quote:
![]() Back in 2013 I posted the code that I used for a textbox with a gray background: https://www.mobileread.com/forums/sho...25&postcount=9 Looks great on color devices + it seemed to work really well on e-ink (Nook) as well. Quote:
https://www.mobileread.com/forums/sho...63#post2571663 This type of stuff can easily be tweaked and learned from... ![]() Last edited by Tex2002ans; 10-14-2016 at 11:20 PM. |
||
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
ePub to azw3 paragraph background-colour | Agama | Conversion | 6 | 01-12-2013 08:26 AM |
White text on white background in dialog boxes | Kikker123 | Kobo Tablets | 1 | 12-24-2011 06:20 PM |
Comments - colour background with links | transmitthis | Calibre | 3 | 12-07-2011 09:02 AM |
LRF background colour? | femgeek | LRF | 0 | 06-20-2011 08:58 AM |
Background colour is always white? | Tissa | Reading and Management | 0 | 11-29-2005 12:46 PM |