![]() |
#91 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,720
Karma: 1759970
Join Date: Sep 2010
Device: none
|
PS - I found this rule:
"All other things being equal, the styles that are defined latest, i.e. written nearest to the actual HTML elements and read by the browser last, will over-rule earlier definitions." so I traced the sequence: Code:
</head> <body class="calibre"> <div class="calibre3" id="calibre_pb_0"></div> <div class="calibre4" id="calibre_pb_1"></div> <h2 class="calibre5" id="heading_id_6"><span class="none1">Chapter 6.</span><br class="calibre6" /> <br class="calibre6" /></h2> <p class="noindent"><span class="none"> ... text..... I still could only made your technique work by adding an explicit margin-bottom defn to my .noindent class .calibre { display: block; font-size: 1em; line-height: 1.2; margin-bottom: 0; margin-left: 0; margin-right: 5pt; margin-top: 0; padding-left: 0; padding-right: 0; page-break-before: always } .calibre1 { display: table-row; vertical-align: middle } .calibre2 { display: block } .calibre3 { border-bottom: 0; border-top: 0; display: block; margin-bottom: 0; margin-top: 0; padding-bottom: 0; padding-top: 0; page-break-after: always; text-indent: 1em } .calibre4 { display: block; page-break-after: always } .calibre5 { display: block; font-size: 1.125em; font-weight: bold; line-height: 1.2; margin-bottom: 0.3em; margin-left: 0; margin-right: 0; margin-top: 1em; text-align: center } .calibre6 { display: block; line-height: 1.2 .none { font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none } |
![]() |
![]() |
![]() |
#92 |
Enquiring Mind
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 562
Karma: 42350
Join Date: Aug 2010
Location: London, UK
Device: Kindle 3 (WiFi)
|
Hi cybmole
The order in which styles appear in the stylesheet has no effect on how they are applied. They can appear in any order in the stylesheet. When theducks referred to placing "noindent" after "calibre10", he was referring to the order in which those classes are listed in the "class" attribute for "p" elements. Example If we have in the stylesheet: Code:
.noindent { text-indent: 0; } .standardpara { margin-top: 1em; margin-bottom: 1em; text-indent: 0.3em; } Code:
<p class="standardpara noindent">bla bla bla</p>
That way, you get all the formatting defined for class "standardpara" (such as the top and bottom margins) except where the formatting defined for class "noindent" specifies something different (the first line indent). The order in which the styles are listed in the stylesheet has no effect whatsoever, but the order in which the classes are listed in the "class" attribute is important, since they are applied in sequence, from left to right, with each one overriding the one(s) to the left where the same CSS properties are defined in each style involved (in this case, the "text-indent" property). In this example, the result is that this paragraph will have the following formatting applied to it: margin-top: 1em; (from "standardpara" style) margin-bottom: 1em; (from "standardpara" style) text-indent: 0; (from "noindent" style, overriding the text-indent value specified in the "standardpara" style, because "noindent" is listed after "standardpara" in the "class" attribute value list) This is one way in which styles "cascade" in CSS, meaning that you shouldn't have to define every aspect of the desired formatting in every single style definition, as long as you use the style hierarchy appropriately. |
![]() |
![]() |
Advert | |
|
![]() |
#93 | ||
Enquiring Mind
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 562
Karma: 42350
Join Date: Aug 2010
Location: London, UK
Device: Kindle 3 (WiFi)
|
Quote:
Code:
</head> <body class="calibre"> <div class="calibre3" id="calibre_pb_0"></div> <div class="calibre4" id="calibre_pb_1"></div> <h2 class="calibre5" id="heading_id_6"><span class="none1">Chapter 6.</span> <br class="calibre6" /> <br class="calibre6" /></h2> <p class="noindent"><span class="none"> ... text.....</p> Quote:
Hope that's helped clarify this a bit further. ![]() |
||
![]() |
![]() |
![]() |
#94 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,720
Karma: 1759970
Join Date: Sep 2010
Device: none
|
thanks - it all makes sense now
- I was wrongly replacing .calibreN with my .noindent style but actually I have to append it, like< p class="calibreN noindent" rather than just <p class="noindent". I should have paid more attention to what theducks ACTUALLY wrote! & I can put .noindent anywhere in the .css file, so I'll simply add it to top or bottom rather than search for an exact location |
![]() |
![]() |
![]() |
#95 |
Enquiring Mind
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 562
Karma: 42350
Join Date: Aug 2010
Location: London, UK
Device: Kindle 3 (WiFi)
|
There are several ways to apply multiple styles to a single element:
1. Enclose the element inside another element. It will inherit the style applied to the element that it's sitting inside, and then its own style will be applied over that. Example CSS: Code:
div { margin-top: 1em; margin-bottom: 1em; } p { text-indent: 0.3em; } Code:
<div> <p>bla bla bla</p> </div> Example CSS: Code:
p { margin-top: 1em; margin-bottom: 1em; text-indent: 0.3em; } .noindent { text-indent: 0; } Code:
<p class="noindent">bla bla bla</p> Example CSS: Code:
.bodytext { margin-top: 1em; margin-bottom: 1em; text-indent: 0.3em; } .noindent { text-indent: 0; } Code:
<p class="bodytext noindent">bla bla bla</p> |
![]() |
![]() |
Advert | |
|
![]() |
#96 | |
Enquiring Mind
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 562
Karma: 42350
Join Date: Aug 2010
Location: London, UK
Device: Kindle 3 (WiFi)
|
Quote:
![]() Glad I was able to help - I could see some confusion had crept in, but it wasn't until you posted those two posts earlier this morning that it became clear where exactly things had got a bit tangled. ![]() |
|
![]() |
![]() |
![]() |
#97 |
Enquiring Mind
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 562
Karma: 42350
Join Date: Aug 2010
Location: London, UK
Device: Kindle 3 (WiFi)
|
Just to add a final note on the whole style hierarchy/cascade thing - there's also a hierarchy in terms of where a style is defined.
There are three main places you can define CSS styles: 1. An external stylesheet (e.g. a file "style.css") referred to in the HEAD section of an HTML file using the LINK element, e.g.: Code:
<link rel="stylesheet" type="text/css" href="../Styles/style.css" /> Code:
<style type="text/css"> p { margin-top: 1em; margin-bottom: 1em; text-indent: 0.3em; } </style> Code:
<p style="margin-top:1em;margin-bottom:1em;text-indent:0.3em;">bla bla bla</p> |
![]() |
![]() |
![]() |
#98 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,720
Karma: 1759970
Join Date: Sep 2010
Device: none
|
I have a book with has <div rather than <p
I managed to get the noindent trick to work after a few false starts but what are the side effects of coding in <div rather then in < p for each paragraph please ? should I attempt a drastic replace of div with p ? Code:
</head> <body class="calibre5"> <p class="calibre3"><a class="calibre4" id="c38"></a></p> <div class="fmhT calibre11 sgc-1"> 38. </div> <div class="tx noindent"> <b class="calibre9">H</b>URRY, ” ALEXSAID, avoiding looking at Jax in her half-naked condition. “Hoffmann is probably raising an alarm, getting together help. The last thing we need is to get trapped in here.” </div> <div class="tx"> Code:
<h2 class="fmhT calibre11 sgc-1" id="heading_id_2">30</h2> <div class="tx noindent"> <b class="calibre9">A</b>LEX DIDN’T REMEMBER OPENING HIS EYES. He didn’t remember waking. He merely became gradually aware that he was awake. After a fashion. </div> font-weight: bolder;text-indent: 0 } .noindent {text-indent: 0} .tx { border-bottom: 0; border-top: 0; display: block; font-size: 0.88889em; line-height: 1.2; margin-bottom: 0.3em; margin-top: 0; padding-bottom: 0; padding-top: 0; text-align: justify; text-indent: 1em } but when I move the above arrangement & place the .noindent defintion below the .tx definition like below, then it works _ I thought you'd said order did not matter in .css ??? .tx { border-bottom: 0; border-top: 0; display: block; font-size: 0.88889em; line-height: 1.2; margin-bottom: 0.3em; margin-top: 0; padding-bottom: 0; padding-top: 0; text-align: justify; text-indent: 1em } .noindent {text-indent: 0} Last edited by cybmole; 02-26-2011 at 09:55 AM. |
![]() |
![]() |
![]() |
#99 |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 31,048
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Cyb
IMHO the down side is on the Human end ![]() ![]() Say you style a <Div> just after the Chapter starting stuff. 45 paragraphs later (you have not closed the <Div>)... What are the style attributes in effect? ![]() BTW I have seen similar to your example CSS many times ![]() ![]() IMHO Body: sets the most used and over all style (size,stroke,face,margins...) a normal paragraph <P> (naked ![]() Now you create classes for the exceptions to the basic <Body> eg. first paragraph narrative (probably just italics) chapter_title (when default H# styling is not enough ![]() BTW HTML has default values built in. You normally do not need to specify them again, unless you are restoring them from a previous change (just more processing that needs to be done by the device ![]() Note: there are broken implementations on some devices that may need to be worked around. ex. a fractional <hr /> is supposed to center by default: It does not in ADE: you have to force the margin-left to 1/2 the remaining (white space) Remember those long-reaching Div's? instead of letting the class expire (like the span did), the <div> holds it until it closes. So you set a bigger margin there, now you have override it everywhere else ![]() K.I.S.S. |
![]() |
![]() |
![]() |
#100 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,720
Karma: 1759970
Join Date: Sep 2010
Device: none
|
that's helpful thanks - but can you look again please - at the final part of my previous post - the bit about how changing where I place .noindent in the list of css styles is affecting the outcome. I'd like to know why that is.
|
![]() |
![]() |
![]() |
#101 | ||
Enquiring Mind
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 562
Karma: 42350
Join Date: Aug 2010
Location: London, UK
Device: Kindle 3 (WiFi)
|
Quote:
Quote:
Problem is the file has become such a soup of fragmented and overlapping CSS styles, it's getting harder and harder to untangle it, and presenting more and more opportunities for small errors and typos to screw things up. If it was me, I'd try to get back to a relatively clean version and start over, rather than continuing to try and hack my way through the undergrowth resulting from multiple conversions etc. |
||
![]() |
![]() |
![]() |
#102 | |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 31,048
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
The order in the CSS (except for duplicate names) has no bearing on the issue. The order in the CLASS= statement does. |
|
![]() |
![]() |
![]() |
#103 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,720
Karma: 1759970
Join Date: Sep 2010
Device: none
|
Quote:
with this html - class="tx noindent" ..... and with this order in css: .noindent .tx the noindent did not work i flip the order within .css to .tx .noindent making NO changes to xhtml and then it did work. the more detailed post is my last but 2. as for "file has become such a soup of fragmented and overlapping CSS styles," - it is just your typical everyday calibre conversion! so , in summary,I am using method 3 of your 4 methods but am finding that css order does matter, at least in this case. Last edited by cybmole; 02-27-2011 at 02:06 AM. |
|
![]() |
![]() |
![]() |
#104 |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 31,048
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
The only way I can see that order change within the CSS affecting what you see, was you managed to 'break' "tx", so it was ignored (at least, that is what ADE, does. A PITA to find. one tiny period or semicolon
![]() ![]() (Been there... Many, many times ![]() |
![]() |
![]() |
![]() |
#105 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,720
Karma: 1759970
Join Date: Sep 2010
Device: none
|
i can now reproduce this effect in other books
where I have a working 1st para of the form <p class="normal noindent">blah.... I just have to cut the noindent definition and move it higher in css, so that it is defined before normal is defined. e.g. make it 1st line of css, right after the @namespace line the noindent property then stops working. ( as viewed in sigil book mode) I am using this simple 1 line formula .noindent {text-indent: 0} I hear all that you say about it shouldn't happen, but it does - maybe sigil is written in a slightly non-compliant way ? please test in sigil. my EXACT sequence: view a chapter of previously fixed up book ,in book mode - see no indent working ok in para 1 - now go to css, move that noindent definition line up to top of css, to back to previous chapter viewed & switch back to book mode in sigil - voila! Last edited by cybmole; 02-27-2011 at 12:21 PM. |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Indents! Please Help! | Ephraim | Sigil | 8 | 11-23-2010 03:43 PM |
Margins and Indents | sloecoach | Calibre | 2 | 09-26-2010 04:41 PM |
Display of Hanging Indents | crutledge | Workshop | 1 | 09-25-2009 06:09 PM |
RFE: Remove remove tags in bulk edit | magphil | Calibre | 0 | 08-11-2009 10:37 AM |
Hanging indents? | llasram | Kindle Formats | 11 | 01-05-2009 10:59 AM |