View Single Post
Old 05-31-2014, 05:15 PM   #10
RbnJrg
Wizard
RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.
 
Posts: 1,821
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by mrmikel View Post
Tables are not easily controllable in epub. Columns will be as wide as the largest item in the column, so you have to shrink text.
You can set the width of columns by styling them with css. For example if you set a TABLE width of 80% (will take 80% of the screen) and a COLUMN width of 30% (will take 30% of the table) then, the column will have a 24% of the screen width.

Regarding center a table, if you, for example, set a table width of 80% you can center it perfectly with a left margin of 10% or (it doesn't work in ADE) by means of margin: 0 auto;.

Try this:

Code:
table {
  width: 80%;
  margin-left: 10%;
  border: 1px solid;
  border-collapse: collapse;
}

th, td {
  text-align: center;
  padding: 5px;
  border: 1px solid;

}

.width30 {
  width: 30%;
}

.width20 {
  width: 20%;
}

.width50 {
  width: 50%;
}
with:

Code:
<table>
    <colgroup>
      <col class="width30" />
      <col class="width50" />
      <col class="width20" />
    </colgroup>

    <tr>
      <th>First Col.</th>

      <th>Second Col.</th>

      <th>Third Col.</th>
    </tr>

    <tr>
      <td>Item #1</td>

      <td>Table with three columns</td>

      <td>- -</td>
    </tr>
</table>
Of course, this table will have problems with the columns width if the col width is (as you said) lower than the largest word in that column. You can reduce this issue by adding soft hyphens to each word inside the table but some ereaders have problems with soft hyphens.

Last edited by RbnJrg; 05-31-2014 at 05:17 PM.
RbnJrg is offline   Reply With Quote