![]() |
#1 |
Connoisseur
![]() ![]() Posts: 61
Karma: 190
Join Date: Sep 2023
Device: Kobo Libra 2
|
CSS Styling based on class/existing styling
Hello!
I have a colour eink device, and it feels like the colour feature is going to a waste when most of my books are black and white. I had the idea of adding colour to any div/p/span/header classes with a certain class or ID, but it misses the occasional text portion. Is there any way to apply styling based on an existing class with the bold/italic styling? Code:
h1, h2, h3, h4, h5, h6, i, em,div[class*="italic"],p[class*="italic"],span[class*="italic"], b, strong { color: #8D4CF6; } span[class*="title"],p[id*="chapter"],div[id*="chapter"],span[id*="chapter"],p[id*="epilogue"],div[id*="epilogue"] ,span[id*="chapter"],span[id*="epilogue"],p[value*="Table of Contents"],p[value*="ToC"] ,div[value*="Table of Contents"],div[value*="ToC"],p[value*="prologue"] ,div[value*="prologue"],div[value*="prologue"] ,span[value*="prologue"] { color: #8D4CF6; } |
![]() |
![]() |
![]() |
#2 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,604
Karma: 9500498
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
|
Where is that code snippet from? Is that your CSS code?
|
![]() |
![]() |
![]() |
#3 |
Connoisseur
![]() ![]() Posts: 61
Karma: 190
Join Date: Sep 2023
Device: Kobo Libra 2
|
Yes, I made it myself. I put it in Preferences..Common options..Styling
It's not the cleanest thing in the world, but works in MOST cases. It misses any text portion where the class names are gibberish or ones that don't use the <i> or <b> tags. I'd like to change it and apply the color to all classes with a specific style attached to it or find another solution... Last edited by 1ily; 03-15-2025 at 10:44 PM. |
![]() |
![]() |
![]() |
#4 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,604
Karma: 9500498
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
|
Oh right. You are adding it in conversion, not actually editing the css in the ebook.
TBH, I have never fiddled with conversion settings as for me it is just easier to edit the css in the ebook. So you are trying to colour the italic text. If it were mine, I would change the <span class="italics"> to the correct <i> tags Then I would create a css entry like this... em, i, .italic { font-style: italic; color: #8D4CF6; } But if you still want to do that in conversion, others will need to advise you. But go ahead and try editing the css directly in a single ebook and see how it works out. |
![]() |
![]() |
![]() |
#5 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,171
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Use the transform styles tool. There you can make rules like if the font-weight is bold add extra properties and so on
|
![]() |
![]() |
![]() |
#6 | |
Connoisseur
![]() ![]() Posts: 61
Karma: 190
Join Date: Sep 2023
Device: Kobo Libra 2
|
Quote:
|
|
![]() |
![]() |
![]() |
#7 |
Connoisseur
![]() ![]() Posts: 61
Karma: 190
Join Date: Sep 2023
Device: Kobo Libra 2
|
|
![]() |
![]() |
![]() |
#8 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,604
Karma: 9500498
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
|
|
![]() |
![]() |
![]() |
#9 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,029
Karma: 144284074
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
I've seen multiple italic classes for different reasons such as an embedded font or sans-serif or monospace, regular italic, bold italic, part of offset text so it has LR margins, etc.
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Styling book comments (description) with CSS | tgiladi | Library Management | 26 | 11-24-2024 07:23 AM |
Does converting to KFX format change or limit the CSS styling of the source file? | jdunning | Conversion | 3 | 08-01-2019 10:35 PM |
Incorrect styling with specific CSS | quiris | Marvin | 9 | 07-04-2016 01:04 PM |
Styling Elements in CSS - ADE and Sony | toskpro | Sony Reader | 0 | 07-19-2010 01:55 PM |
CSS Styling not showing up in digital editions | sjkramer | Sigil | 9 | 01-30-2010 10:46 AM |