![]() |
#1 |
Member
![]() Posts: 22
Karma: 10
Join Date: Oct 2021
Location: Stuttgart, Germany
Device: Galaxy Tab S7+
|
CSS problem: table-design
Dear all,
I hope my question doesn't appear too stupid to you - but I'm not an expert with css, and I have not found an answer on google. I designed a table for my epub in css via Code:
table.DeclensionTable { background-color: #FFF; width: 60%; text-align: left; border: none; border-collapse: collapse; margin-right: auto; margin-left: 50px; } Code:
<table class="DeclensionTable" style="width: 80%"> The length is variable here, can be 80%, 90% or whatever ... Is there a better way to achieve this? Best wishes, Frank |
![]() |
![]() |
![]() |
#2 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,087
Karma: 447222
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
|
FWIW, I've always found Tables to be tricky so I made my CSS as simple as i could
Sometimes inline CSS and sometimes CSS classes Here's just my example for both, with <td style="width: 35%"> the inline and <td class="second">2</td> the clsss Spoiler:
Using Spoiler:
Just some things to consider |
![]() |
![]() |
Advert | |
|
![]() |
#3 | |
Member
![]() Posts: 22
Karma: 10
Join Date: Oct 2021
Location: Stuttgart, Germany
Device: Galaxy Tab S7+
|
Quote:
![]() While reading your answer, I had the following idea: Code:
<table class="DeclensionTable SmallTable" style="width: 80%"> Thanks for answering! |
|
![]() |
![]() |
![]() |
#4 |
Running with scissors
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,586
Karma: 14328510
Join Date: Nov 2019
Device: none
|
Having a style= and a class= seems odd to me but here's what I tried just now which worked but which you may find odd. To be honest any style= on a tag is a bad smell for me.
In the css for the table, set its width to 100%; Code:
table { width: 100%; } Code:
.tablebig { width: 80%; } .tablesmall { width: 40%; } Code:
<div class="tablesmall"> <table> ... |
![]() |
![]() |
![]() |
#5 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,087
Karma: 447222
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
|
@hobnail --
That's sort of the way I do it in my CSS - first spoiler in post #2. You're right that it's not very portable: different tables in same epub might have different column widths, each epub need to be tweaked, etc. |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Running with scissors
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,586
Karma: 14328510
Join Date: Nov 2019
Device: none
|
Yes, just get rid of the div and put the classes on the table.
|
![]() |
![]() |
![]() |
#7 |
Member
![]() Posts: 22
Karma: 10
Join Date: Oct 2021
Location: Stuttgart, Germany
Device: Galaxy Tab S7+
|
Sorry, that was my mistake.
Here's what I meant: Code:
<table class="DeclensionTable SmallTable"> For my purposes, it is a satisfying solution. Thank you very much for your help! ![]() |
![]() |
![]() |
![]() |
#8 | |
Running with scissors
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,586
Karma: 14328510
Join Date: Nov 2019
Device: none
|
Quote:
Yes, I use something similar. I have a "block" div that is generic for setting things off from the paragraphs: Code:
div.block { margin-left: auto; margin-right: auto; margin-top: 1em; width: 85%; } Code:
div.article { font-family: sans-serif; } div.letter p { font-style: italic; hyphens: none; } Code:
<div class="block letter"> Last edited by hobnail; 04-27-2022 at 04:41 PM. |
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Create table of contents with CSS tags | spartanhooah | Editor | 11 | 05-21-2020 10:02 PM |
CSS Table Styles: Does it work? | Alan Newson | ePub | 3 | 12-12-2011 03:54 PM |
CSS to emulate table, or...? | Hitch | ePub | 8 | 06-04-2011 08:35 PM |
Table emulation CSS, or...? | Hitch | Sigil | 34 | 09-23-2010 11:59 AM |
CSS for auto Table of Contents | MaryBon | Calibre | 1 | 09-21-2010 06:17 AM |