![]() |
#1 |
Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 541
Karma: 1152752
Join Date: Aug 2010
Location: Evansville, IN, USA
Device: Samsung Galaxy Tab 4 Nook & Samsung Galaxy Tab S 10.5
|
Confusing global definitions in css
I don't know if this is the best place to post this or not. It's more of a coding issue than a Sigil issue so I'm going to try here.
Typically, most css that I edit are mostly made up of various class definitions. I'm try to clean up/improve an epub that only has a couple of class definitions and is made up mostly of global definitions. Here are some examples: p { margin: 0px 0px 0px 0px; font-family: Times New Roman; } p + p { text-align: justify; text-indent: 12px; margin-top: 0px; } p + p b { text-align: justify; text-indent: 12em; margin-top: 0px; } OK, I know p is paragraph. So all paragraphs with no other class assigned would default to the global p definition. Now, what are p + p and p + p b and when would they come into play? I've never ran into these before. Any light anyone could shed into this for me would be greatly appreciated. Thanks. - Byron |
![]() |
![]() |
![]() |
#2 | |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
It is an adjacent selector: http://www.w3.org/TR/CSS2/selector.h...ttern-matching
Quote:
|
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 541
Karma: 1152752
Join Date: Aug 2010
Location: Evansville, IN, USA
Device: Samsung Galaxy Tab 4 Nook & Samsung Galaxy Tab S 10.5
|
OK. Gotcha. Thanks!
So p + p would be consecutive paragraphs. p + p b would be any paragraph with bold characters following a paragraph? That one seems sort of strange but I think that's what it would be. Thanks for your help. - Byron |
![]() |
![]() |
![]() |
#4 | |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
Quote:
Try thinking of it as tags, since the fact that <b> creates bold text doesn't have anything to do with the nature of the CSS inheritance. ![]() You can have a <span style="font-weight:bold;">bolded text</span> with, you guessed it, bold characters. "p+p b" would not match a span tag, and these bolded characters would not receive that CSS. But if the only bolding was done via the <b> tag, it would work as you expect. ![]() Hopefully, this is a little clearer. Last edited by eschwartz; 03-18-2014 at 11:21 PM. Reason: typo |
|
![]() |
![]() |
![]() |
#5 |
Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 541
Karma: 1152752
Join Date: Aug 2010
Location: Evansville, IN, USA
Device: Samsung Galaxy Tab 4 Nook & Samsung Galaxy Tab S 10.5
|
Definitely! Thank you very much for your help. Most of the books that I deal with have pretty standard classes setup, or very simple globals like div, p, img. It's only been recently that I've started to run into these.
I really appreciate your help. - Byron Last edited by bfollowell; 03-19-2014 at 02:18 AM. |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
Sure, anytime.
![]() |
![]() |
![]() |
![]() |
#7 | |
frumious Bandersnatch
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,546
Karma: 19001583
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
Quote:
p + p applies to any paragraph following a paragraph, but still the basic p applies too, so they are justified and Times New Roman as well. p + p b applies to any <b> tag inside a <p> following another <p> and, since what this style constains is text-align, text-indent and margin-top, it's pretty useless, because the <b> tag is inline, and those properties have no meaning there. |
|
![]() |
![]() |
![]() |
#8 |
Color me gone
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,089
Karma: 1445295
Join Date: Apr 2008
Location: Central Oregon Coast
Device: PRS-300
|
I have some question whether this sort of construction is wise, whether it is permitted or not.
If you have too much stuff cascading it can take some work to figure out what is operating on any given paragraph and it might take some thought to edit the mess too without creating unintended consequences. If course if Bryon has this stuff incoming, all he can do is duck! (grin) |
![]() |
![]() |
![]() |
#9 | |
frumious Bandersnatch
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,546
Karma: 19001583
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
Quote:
Code:
p { margin: 0; text-indent: 1.5em; text-align: justify; } h1 + p { text-indent: 0; } - I'm sure you want justification in the first paragraph too. - No need to set margin-top again, when the margin was already set before. - Rather than having a special selector for when you want indents, have one for when you don't want them (h1+p, as an example). With p+p you don't get indents in a <p> after a <div class="illustration">. Ideally, you wouldn't even specify margins or text-align (maybe not even text-indent:1.5em), that should be set by the reader. |
|
![]() |
![]() |
![]() |
#10 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,624
Karma: 3120635
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
|
Quote:
I would say it a little differently. I propose: " Do not name a base font without providing an easy way out". I think that any reader worth this name can change easily a base font if it's only named once in the body. I have two reasons for doing so: 1. - Not all the fonts provide "espaces fines" (nnbsp) even if readers using ADE 2.0 and above can read them automatically. So, I have been used to provide one font that does it as a base font. I'll add it as an attribute in the body once for all. There is a draw back that I heard of: some few ebook-readers - like the Nook I think? - do not recognize such an attribute in this place, but I think it's valid and standard compliant code, so I just do not pay it more attention than to some iBooks quirks (To be true, I sell nothing ![]() 2. - The other reason is that I like to provide PDF too (using a very nice Jellby's script) straight from my EPUB. For PDF, it's better to provide a base font because it will do nothing on its own. Last edited by roger64; 03-20-2014 at 12:11 AM. |
|
![]() |
![]() |
![]() |
#11 |
Color me gone
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,089
Karma: 1445295
Join Date: Apr 2008
Location: Central Oregon Coast
Device: PRS-300
|
I sell nothing either. The commercial ebook world is a much less pleasant place full of mutually exclusive/contradictory/.... requirements. I have no one to please but myself, but try to think of the users of the books I transcribe.
|
![]() |
![]() |
![]() |
#12 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,552
Karma: 204127028
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
When I create an ebook (and I don't do it commercially at all), I do so with the assumption that some future disaster will result in the loss of massive amounts of literature (both physical AND digital) that can only be "reclaimed" from personal archives. So when they eventually discover that box full of thumbdrives in the ruins of my home, they will be amazed by the trove of simple, clean, complete, and easy-to-edit/convert representations of lost treasures that they find there.
|
![]() |
![]() |
![]() |
#13 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,306
Karma: 13057279
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
Quote:
![]() This is the proper way to think! Clean the books as best as you can, with as minimal/clean code as possible, to the best of your ability. I look back on a few of my earlier EPUBs, and I just think "wow, that is bad" or "what the hell was I thinking?" Example: Avoid captions in images LIKE THE PLAGUE. Example: Try to avoid lossy conversions (JPG), and keep things in lossless if you can (PNG). Once you go lossy, you can never go back! My main goal is digitizing works which are only in scans (or not online at all), a subgoal is "maintenance" of the ebook backlog... continually going back and fixing up the old code to match my newest standards.... a lot like any large programming project! Or think of it this way, even IF you are creating these books "only for yourself", you will be converting these books to future formats and be your own "customer/reader/user" ten years down the line. I try to stress this to others here too, you will save yourself a lot of future headaches if you try to make it RIGHT the FIRST time. Last edited by Tex2002ans; 03-20-2014 at 06:45 PM. |
|
![]() |
![]() |
![]() |
#14 |
Color me gone
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,089
Karma: 1445295
Join Date: Apr 2008
Location: Central Oregon Coast
Device: PRS-300
|
You're doing it commercially, Tex2002ans.
For me, not everything worth doing is worth doing perfectly. Getting it good enough to read and enjoy is good enough. Links to and from footnotes etc. are more trouble than they are worth to me. |
![]() |
![]() |
![]() |
#15 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,306
Karma: 13057279
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
Quote:
![]() Example: One of my other side projects is "redoing" a lot of the books that were previously converted by an Indian conversion company. They use spaghetti code + hideous code + unmaintainable junk. Sure, it may LOOK pretty, and work ok FOR NOW in EPUB/current devices. But when the next ebook generation comes along, I bet you these books will break and be a complete pain to transfer over. Anyway... sort of getting side-tracked from the main post. ![]() Last edited by Tex2002ans; 03-23-2014 at 09:28 PM. |
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
sigil_split_marker and other CSS definitions; where are they? | rceee | Sigil | 6 | 03-10-2013 08:25 PM |
Arc confusing | stevov | Kobo Tablets | 1 | 01-12-2013 04:58 PM |
Global css | triplemaya | Sigil | 9 | 12-04-2011 07:17 PM |
How to maintain a global CSS stylesheet | amoroso | Sigil | 7 | 07-18-2010 08:37 PM |