![]() |
#1 |
Obsessively Dedicated...
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,213
Karma: 34984928
Join Date: May 2011
Location: JAPAN (US expatriate)
Device: Sony PRS-T2, ADE on PC
|
How to constrain Table Width
My search skills have failed, and I can't discover if there is a way to do this, or if it is not supported.
I would like to make a CENTERED paragraph, OR a single-cell table, with a border on all four sides. If I use Margins: Auto, it displays fine in Sigil, but ADE makes the box the full width of the window. leaving a wide strip of white space down each side of the text. So I guess auto-margins are not supported everywhere. If I use Width: (ems or percentage here), it comes closer to what I want, but when the reading screen is narrow, it causes the lines to break in unattractive places. Am I stuck with using this method, and using nbsp to force the line-breaks to better places? Also, if I set to a wider width, then again I have the large swatches of white space down each side. --- PS: I forgot to mention that this is a fairly narrow paragraph, and would display about 20 to 30 characters per line. Another similar one would be only 8 characters. If I can't find a better method, I guess I might have to give up the idea of borders... Last edited by GrannyGrump; 03-18-2013 at 04:54 AM. Reason: additional info |
![]() |
![]() |
![]() |
#2 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
|
According to the specs, auto margins are free to interpret. That results into the fact that this does not work in ADE as desired and expected. The problem is, that centering is only applied to the inline elements. What you can try is the following:
In your stylesheet: Code:
.wrap {text-align:center} .center {text-align:center; width: 60%; display:inline-block} .centerleft {text-align: left; width: 60%; display:inline-block } Code:
<div class="wrap"> <p class="center">Here is some text that should be centered</p> <p class="centerleft">Here is text that is left aligned in the center. As you can see this is quite nifty.</p> </div> |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Color me gone
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,089
Karma: 1445295
Join Date: Apr 2008
Location: Central Oregon Coast
Device: PRS-300
|
You are not the only one frustrated. I do a lot of non-fiction full of tables. It seems impossible to center it. If you use a trick shown on a Liz Castro blog, it centers, but the table elements break up into odd lines. Anything else leaving it normal doesn't center it.
If you aren't trying to make it for anyone but yourself make the table the width of your device, minus a bit. At least it won't be so obvious. You can control the table width, in one view at least, by changing text size and inserting breaks so the columns aren't overly wide. For your narrow column you can put the border information into each td you want to show. It should not be this hard, but it is, for me anyway. If I have the original source I use images rather than go through all this. Images I can center. |
![]() |
![]() |
![]() |
#4 |
eBook Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 85,544
Karma: 93383099
Join Date: Nov 2006
Location: UK
Device: Kindle Oasis 2, iPad Pro 10.5", iPhone 6
|
Feel free to shoot me, but the deprecated but still functional "<center>" tag works extremely well for this.
ie: Code:
<center> <table width=30% border=1> <tr> <td>This is a centred table</td> </tr> </table> </center> |
![]() |
![]() |
![]() |
#5 |
Color me gone
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,089
Karma: 1445295
Join Date: Apr 2008
Location: Central Oregon Coast
Device: PRS-300
|
Since Sigil complains about it I haven't been using it, but it does work and it works fine for my Sony. I will just use it and ignore Flight Crew.
|
![]() |
![]() |
Advert | |
|
![]() |
#6 | |
eBook Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 85,544
Karma: 93383099
Join Date: Nov 2006
Location: UK
Device: Kindle Oasis 2, iPad Pro 10.5", iPhone 6
|
Quote:
But I too generally use an image for a complex table - it's often the most hassle-free way of doing it. The centred table code I posted, though, I've used quite a lot where I want to have a centred paragraph with a border - it's useful in books for things like business cards, signs, notices, etc. |
|
![]() |
![]() |
![]() |
#7 |
Obsessively Dedicated...
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,213
Karma: 34984928
Join Date: May 2011
Location: JAPAN (US expatriate)
Device: Sony PRS-T2, ADE on PC
|
Thank you all for the suggestions. I have done a tiny bit of experimenting.
The problem was mostly that, if I set "width" to a percentage, I could not keep the borders close to the text if the screen width changes, they floated way out to the sides. Now I have tried setting the width at ems instead of percentage, and using <center> as suggested by Harry, and I think this is as close as I will get to my wishes. I just must make sure I specify enough ems to hold the width of the longest line. Toxaris, that IS pretty nifty. And if I set the widths narrower, I can have two paragraphs side-by-side. I wish I had known about this before, I know just the project it would have helped. mrmikel, I have given up trying to center tables. I mostly let them sit left-aligned on the page, and who doesn't like it doesn't have to look. Although I might try using <center> in future. Thank you all again. |
![]() |
![]() |
![]() |
#8 |
Writer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 101
Karma: 590630
Join Date: Mar 2011
Location: Munich, Germany
Device: none
|
In my example the tables are centered. The border of the cell fits to the text, because the width of the table is only 5% with the text expanding the cell.
To avoid line breaks I have added the <nowrap> attribute to <td> except where I want a line break (in the second table). This is done with <br>. I don't know what happens if the screen of the device is narrower than the longest line (30 characters). I'm afraid part of the text will be hidden. But then the device would be very (!) small. The formatting is in old style html, but you can do it in CSS as well. George |
![]() |
![]() |
![]() |
#9 |
Obsessively Dedicated...
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,213
Karma: 34984928
Join Date: May 2011
Location: JAPAN (US expatriate)
Device: Sony PRS-T2, ADE on PC
|
Ah, thank you GMcG, the nowrap must be the secret word! This works beautifully!
I still have SO much to learn, it seems like an endless education. |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Constrain Proportions of Cover Image? | markjoseph | ePub | 7 | 12-31-2010 12:54 PM |
Anyone know how to convert a pdf table into a table in Word or HTML? | BasilC | Workshop | 7 | 06-25-2010 01:02 AM |
Page Width | kobo2010 | Kobo Reader | 4 | 05-10-2010 08:14 PM |
Sideway Table in ePub (Rotate table/text) | Lapiz | ePub | 3 | 01-29-2010 01:11 PM |
Forget coffee table books-- how about a kitchen table book? | ardeegee | Lounge | 10 | 12-02-2009 12:00 PM |