View Full Version : need help on how to align a table to the right


NASCARaddicted
01-03-2011, 05:37 PM
Hello

I have a small table that I want to align to the right with CSS. I tried different things, and they look good in Firefox and in the ebook viewer of Calibre, but when I put the epub-file on my ebook-reader (Bebook with ADE), the table is not right aligned, it is aligned to the left.

Here is what I tried so far, after some Google search:

.tabrechts {border-style:hidden; border-collapse: collapse; margin-right: 0em; margin-left: auto;}

and I also tried

.tabfloat {border-style:hidden; border-collapse: collapse; width:auto; float:right;}

As I said, it looks good in Firefox and Calibre, but once it ends up on my ebook-reader, the table is on the left side.

Can anyone help me, please? Am I doing something wrong?

Jellby
01-04-2011, 05:25 AM
ADE treats "auto" margins as "0", which is allowed in the ePUB spec. Try "margin-right: 0" instead, or wrap the table in a <div> with "text-align: right" (you may have to set the aligment inside the table again, or the cells will be right-aligned too).

NASCARaddicted
01-04-2011, 12:03 PM
ADE treats "auto" margins as "0", which is allowed in the ePUB spec. Try "margin-right: 0" instead, or wrap the table in a <div> with "text-align: right" (you may have to set the aligment inside the table again, or the cells will be right-aligned too).

I already tried margin-right:0, together with margin-left: auto. So do you mean I should remove the margin-left part?

Well, I will give both your ideas a try. Thanks in advance.

NASCARaddicted
01-04-2011, 02:34 PM
so, I just tried, but with no success.

At first I removed the margin-left: auto, I just left the margin-right at 0. Now, even in Firefox the table is left aligned - so that is the exact opposite of what I wanted.

Then I tried it with div text align right and a table with no margins at all, but it was the same: the whole table is on the left.

Am I doing something wrong, or am I just stupid? Or what else could be the problem?

Jellby
01-05-2011, 06:52 AM
What's the width of the table? Can we see a sample?

NASCARaddicted
01-05-2011, 01:11 PM
What's the width of the table? Can we see a sample?

The table itself is not very width. It only has 1 column. Actually I only need it for text. Maybe there are other possible ways besides using a table ...

anyway, here is table (or the text of the table):

Karl Blomquist, Privatdetektiv
Adr.: Hauptstraße 14, Kleinköping.«

You see, this is the end of a letter. I want this text to be on the right side of the page, but I want it to be left-aligned. So I thouhgt I put this 2 lines in a table, use "align: left" on the table column and then right align the whole table.

But somehow I didn't manage to do it.

Maybe there are other ways to achieve what I want. I also thought about using blockquote, but this didn't work either.

hard13
02-18-2011, 02:46 PM
have you tried table align?