Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 05-07-2016, 01:26 PM   #1
MacEachaidh
Browser
MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.
 
MacEachaidh's Avatar
 
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.
MacEachaidh is offline   Reply With Quote
Old 05-07-2016, 06:31 PM   #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,768
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by MacEachaidh View Post
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.
Something like this?

Click image for larger version

Name:	Image1.png
Views:	358
Size:	74.9 KB
ID:	148527

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;
}
Below you can check the respective epub so you can understand better the code I used.

Regards
Rubén
Attached Files
File Type: epub Background Color.epub (2.5 KB, 364 views)
RbnJrg is online now   Reply With Quote
Advert
Old 05-07-2016, 09:04 PM   #3
MacEachaidh
Browser
MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.
 
MacEachaidh's Avatar
 
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.
MacEachaidh is offline   Reply With Quote
Old 05-07-2016, 09:27 PM   #4
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 21,725
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by MacEachaidh View Post
Thanks for the reply.

Something like that, yes, but applied to specific paragraphs -- like text boxes in print media -- rather than the whole document.
In the stylesheet create a p_yellow class that is same as existing p class, move the background:yellow out of body into the p_yellow class, and then use p_yellow to style the relevant paragraphs.

Suggested reading. Pablo's tutorial ==>> https://wiki.mobileread.com/wiki/EPub_Tutorial

Last edited by BetterRed; 05-07-2016 at 10:05 PM.
BetterRed is offline   Reply With Quote
Old 05-07-2016, 11:28 PM   #5
GeoffR
Wizard
GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.
 
GeoffR's Avatar
 
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>
The box doesn't interfere with the flow of the text, it will break between pages as normal.
GeoffR is offline   Reply With Quote
Advert
Old 05-08-2016, 05:33 AM   #6
Notjohn
mostly an observer
Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.Notjohn ought to be getting tired of karma fortunes by now.
 
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.
Notjohn is offline   Reply With Quote
Old 05-12-2016, 06:04 AM   #7
Freeshadow
temp. out of service
Freeshadow ought to be getting tired of karma fortunes by now.Freeshadow ought to be getting tired of karma fortunes by now.Freeshadow ought to be getting tired of karma fortunes by now.Freeshadow ought to be getting tired of karma fortunes by now.Freeshadow ought to be getting tired of karma fortunes by now.Freeshadow ought to be getting tired of karma fortunes by now.Freeshadow ought to be getting tired of karma fortunes by now.Freeshadow ought to be getting tired of karma fortunes by now.Freeshadow ought to be getting tired of karma fortunes by now.Freeshadow ought to be getting tired of karma fortunes by now.Freeshadow ought to be getting tired of karma fortunes by now.
 
Posts: 2,815
Karma: 24285242
Join Date: May 2010
Location: Duisburg (DE)
Device: PB 623
Quote:
Originally Posted by Notjohn View Post
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.
Amen to that
Freeshadow is offline   Reply With Quote
Old 05-12-2016, 08:53 AM   #8
HarryT
eBook Enthusiast
HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.
 
HarryT's Avatar
 
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.
HarryT is offline   Reply With Quote
Old 10-14-2016, 12:27 PM   #9
MacEachaidh
Browser
MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.
 
MacEachaidh's Avatar
 
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.
MacEachaidh is offline   Reply With Quote
Old 10-14-2016, 12:52 PM   #10
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
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.
JSWolf is offline   Reply With Quote
Old 10-14-2016, 03:54 PM   #11
MacEachaidh
Browser
MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.MacEachaidh ought to be getting tired of karma fortunes by now.
 
MacEachaidh's Avatar
 
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.
MacEachaidh is offline   Reply With Quote
Old 10-14-2016, 11:16 PM   #12
Tex2002ans
Wizard
Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.
 
Posts: 2,306
Karma: 13057279
Join Date: Jul 2012
Device: Kobo Forma, Nook
Quote:
Originally Posted by JSWolf View Post
The problem with a background color is that on eInk it might be hard to read the text.
Definitely something to always keep in mind.

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:
Originally Posted by MacEachaidh View Post
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.
You may also want to look at this other example CSS for a "blog post" I pulled out of a Tor book:

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.
Tex2002ans is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
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


All times are GMT -4. The time now is 06:52 PM.


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