06-13-2014, 04:55 AM | #1 |
Wizard
Posts: 1,023
Karma: 10963125
Join Date: Mar 2013
Location: Guben, Brandenburg, Germany
Device: Kobo Clara 2E, Tolino Shine 3
|
CSS: margin-top and margin
At formatting the <p> in the css of an epub in Sigil, I wished to create a certain distance between single paragraphs. Thus, I added
margin-top: 2em; O.k. it worked. Only that I found that 2em is a little too much. So I changed the margin-top to 1em, and, surprise: nothing changed, though trying several times. The space between the paragraphs could not be manipulated anymore. Then, I looked in other epubs; in one of them, I found, instead of margin-top, simply: margin: 1 0; I adapted this to my ebook, and, hoops, the margin changed. Could somebody, please, explain to me what has happened, and what has been my mistake? |
06-13-2014, 07:49 AM | #2 |
Color me gone
Posts: 2,089
Karma: 1445295
Join Date: Apr 2008
Location: Central Oregon Coast
Device: PRS-300
|
You apparently set it to px, by leaving off a unit. It looks like you changed the left and right margin as well.
Look here: http://www.w3schools.com/css/css_margin.asp |
Advert | |
|
06-13-2014, 10:31 AM | #3 | |
Resident Curmudgeon
Posts: 73,998
Karma: 128903378
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
Code:
p { margin-top: .3em; margin-bottom: .3em } But personally, I'd change the .3em to 0 so there's no paragraph spaces. I'm not a fan of them. |
|
06-13-2014, 10:34 AM | #4 | |||
Addict
Posts: 398
Karma: 96448
Join Date: Dec 2013
Device: iPad
|
Doesn't seem to be the error in what he did actually.
The margin property can be used in a number of ways: 1. set 1 value which will mean you set a specific value for all sides. Quote:
Quote:
Quote:
In any case, you have to apply both margin-top and margin-bottom to get the margins between paragraphs you want or you can just use line-height but I found that worked less efficiently on some books so stick to margins. |
|||
06-13-2014, 10:37 AM | #5 |
Resident Curmudgeon
Posts: 73,998
Karma: 128903378
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
I'm not. I find the lazy margin harder to read. It's easier to have all four margins separate because it is easier to read at a quick glance.
|
Advert | |
|
06-13-2014, 12:41 PM | #6 |
frumious Bandersnatch
Posts: 7,516
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
|
06-13-2014, 12:54 PM | #7 |
Resident Curmudgeon
Posts: 73,998
Karma: 128903378
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
From http://www.w3schools.com/css/css_margin.asp
Code:
margin: 25px 50px 75px 100px; top margin is 25px right margin is 50px bottom margin is 75px left margin is 100px |
06-13-2014, 02:19 PM | #8 | |
Addict
Posts: 398
Karma: 96448
Join Date: Dec 2013
Device: iPad
|
Yep, if you follow the clockwise sense then you get:
Quote:
|
|
06-13-2014, 02:36 PM | #9 |
Resident Curmudgeon
Posts: 73,998
Karma: 128903378
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
This is just so much easier to read...
Code:
.margins { margin-top: 20px; margin-bottom: 50px; margin-left: 75px; margin-right: 100px } |
06-13-2014, 04:01 PM | #10 |
Addict
Posts: 398
Karma: 96448
Join Date: Dec 2013
Device: iPad
|
|
06-13-2014, 04:12 PM | #11 |
Resident Curmudgeon
Posts: 73,998
Karma: 128903378
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
|
06-14-2014, 02:48 AM | #12 | |
frumious Bandersnatch
Posts: 7,516
Karma: 18512745
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
Quote:
On the other hand, it's much simpler to write "{margin:1em}" than detailing all four margins. I use different forms depending on what I want. |
|
06-14-2014, 10:39 PM | #13 |
Resident Curmudgeon
Posts: 73,998
Karma: 128903378
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
I'll still be writing margins separately. It's just easier to me. I don't have to remember all the different permutations. Besides, in most cases, I don't need more then two margins.
|
06-15-2014, 06:11 AM | #14 | |
Wizard
Posts: 2,297
Karma: 12126329
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
Quote:
Also, there is that ol' Nook Touch (?) bug that some users ran across because they were using the short-hand form of margin. Last edited by Tex2002ans; 06-15-2014 at 06:13 AM. |
|
06-15-2014, 05:22 PM | #15 |
Resident Curmudgeon
Posts: 73,998
Karma: 128903378
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
I've not seen any nook bug with the short form for margins. But, I've not read that much on my nook STR.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Aura HD How to modify the top margin? | scoky | Kobo Developer's Corner | 4 | 04-20-2014 02:10 PM |
CSS margin instead of margin-top, etc. | icallaci | Conversion | 24 | 10-19-2013 09:52 AM |
@page { margin-bottom: 5.000000pt; margin-top: 5.000000pt; } | cybmole | Conversion | 15 | 02-12-2011 11:57 AM |
Top Margin in epub | penguintri | ePub | 8 | 05-08-2010 08:37 PM |
calibre ignore margin-top and margin-bottom | bender | Calibre | 2 | 12-11-2009 06:58 AM |