Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Viewer

Notices

Reply
 
Thread Tools Search this Thread
Old 09-21-2025, 05:02 PM   #1
Valjean
Junior Member
Valjean began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Sep 2025
Device: none
Viewer Styles CSS margin on body ignored

Hello,

First of all, thanks for the great application!!
I am trying to create a "custom" layout by using the Styles configuration.
In the previous versions this seemed to work, but in the newer versions it is not working anymore.
I am trying to add more margin on top and on the bottom, but I am not sure how to do that. Also the images seem to not be aligned correctly.

here is my css:

p, h1, h2, h3, h4, h5{
font-family: Bookerly !important;
margin-left: 6em !important;
margin-right: 6em !important;
line-height: 1.8 !important;
}


body {
height: 85% !important; <- does nothing
margin-top: 40px !important;
margin-bottom: 40px !important;
text-align: center !important;
font-size: 24px !important;
}

div{
margin-left: 1.25em !important;
}

* {
color: rgb(0,0,0) !important;
}

Click image for larger version

Name:	problem.jpg
Views:	26
Size:	443.6 KB
ID:	218215

Thanks for your help
Valjean is offline   Reply With Quote
Old 09-21-2025, 10:58 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,524
Karma: 28548962
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
If you want to add page margins use the setting for that in the viewer preferences.
kovidgoyal is online now   Reply With Quote
Old Yesterday, 04:13 AM   #3
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: 80,282
Karma: 148951761
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
1.8 is much too high a line height.
JSWolf is offline   Reply With Quote
Old Yesterday, 11:42 AM   #4
Valjean
Junior Member
Valjean began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Sep 2025
Device: none
Thank you for the reply. I tried that, but unfortunately, that does not work.
It just cuts of from top and bottom of the picture, instead of pushing the text down (or up).
Please see the picture below.

What is interesting, is that in the past I could keep the background untouched and "push" the text from top and bottom without touching the background. Something has changed from previous versions. I used to replace the viewer.js or viewer.html with some back-up files I had and it worked ok. Now it does not work anymore. (could be that I may have lost the old back-up files - I reinstalled my linux system).
I tried a few older versions (7.1.0, 7.2.0, etc) but I did not find the one that works

Thanks again for your help.


@JSWolf, but I want the text to be spaced out. This is the line height I prefer. Do you mean it has a negative impact on the page overall?
Click image for larger version

Name:	Screenshot From 2025-09-22 18-29-48.jpg
Views:	16
Size:	458.0 KB
ID:	218222
Valjean is offline   Reply With Quote
Old Yesterday, 03:41 PM   #5
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,524
Karma: 28548962
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Use the official calibre binaries and you will be fine. The margins specified in the viewer settings do push the text down and leave the background picture unaffected in current calibre versions >= 8.4
kovidgoyal is online now   Reply With Quote
Old Yesterday, 07:57 PM   #6
Valjean
Junior Member
Valjean began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Sep 2025
Device: none
First of all thank you very much for the fast reply!!
I realize now that my explanations were not very clear.
Since I do not want to waste too much of your time, I give it one more try

I am on Calibre 8.10.
Below there are 3 pictures that show what I mean better.

Picture 1: No margin. As expected, text is too close to the edge of the picture (in some cases the text would go outside of the "book page" in the background).
Picture 2: I set margins of: Left: 50, Right: 60, Top: 60, Bottom: 60. The text is indeed pushed from all sides, however, you can see that the background image is cropped (i.e. the header, footer and the left and right bars overlap the background image).
Picture 3: A quick and dirty photoshoped image that shows how I would expect that the final result looks like (i.e. the background image is scaled down and the header, footer and the left and right bars do not overlap it). The text fits better within the background "book page".

I understand that the margins are not supposed to affect the background image. I guess the better question is how can I achieve the result in Picture 3. Maybe there are other options .
Thanks again!!!

Click image for larger version

Name:	1. no margin.jpg
Views:	8
Size:	489.2 KB
ID:	218228Click image for larger version

Name:	2. what_calibre_does.jpg
Views:	10
Size:	442.5 KB
ID:	218229Click image for larger version

Name:	3. what_I_expect.jpg
Views:	9
Size:	405.4 KB
ID:	218230

Last edited by Valjean; Yesterday at 08:00 PM.
Valjean is offline   Reply With Quote
Old Yesterday, 09:20 PM   #7
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,524
Karma: 28548962
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
I cannot replicate that, steps I tried:

1) Set a background image in the Styles section of the viewer with style set to scaled
2) Change the page margins to 80 in the page layout section
3) The background image appears under the wider margins, as expected
kovidgoyal is online now   Reply With Quote
Old Yesterday, 10:05 PM   #8
Valjean
Junior Member
Valjean began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Sep 2025
Device: none
Thanks a lot! Your comment helped! I found the issue.
The color scheme was the problem.


In your predefined color schemes, the margins have transparent background. How can I make the background transparent for the margins, in my color scheme?

Thanks!!
Valjean is offline   Reply With Quote
Old Yesterday, 10:34 PM   #9
Valjean
Junior Member
Valjean began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Sep 2025
Device: none
Maybe one additional hint. Please feel free to completely ignore it .

It seams that there is no clear separation between what margin means and what header and footer means (configuration wise).

In my case I would like to increase the margins by 50 for example, keep the background for the margin transparent, but, I would like the header and footer to have a different background (for visibility purposes). However, the header and the footer should not occupy the whole margin. I hope it makes sense.

At the moment, I can change the background of the margin!! not the background of header and the footer.


Not a big issue I can still achieve the result I want that by adjusting the background image.
Thanks again for the support!
Valjean is offline   Reply With Quote
Old Yesterday, 10:46 PM   #10
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,524
Karma: 28548962
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Quote:
Originally Posted by Valjean View Post
In your predefined color schemes, the margins have transparent background. How can I make the background transparent for the margins, in my color scheme?
Dont change it from default in your color scheme
kovidgoyal is online now   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
font-family in <body> HTML or body{} CSS? enuddleyarbl ePub 22 10-14-2022 10:52 PM
In CSS, * or body? Arios ePub 10 11-03-2015 10:15 AM
CSS: margin-top and margin Leonatus ePub 16 06-16-2014 04:29 AM
CSS <body> vs. <p> question Amalthia Conversion 7 01-21-2014 01:50 AM
CSS margin instead of margin-top, etc. icallaci Conversion 24 10-19-2013 09:52 AM


All times are GMT -4. The time now is 12:44 AM.


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