Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Right align a table cell

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #38896
    braaf
    Member

    The following fiddle shows a 2×3 css table layout with 5 cells.
    http://jsfiddle.net/BeBum/
    Now, I want cell no. 2 to be right aligned, positioned above cell no. 5.
    I could just add an empty cell between 1 and 2, but what if the table has a variable width
    and you don’t know the number of cells in a row ? Could be 4 or 7.
    I want the no. 2 cell to always be at the utmost right position of the table.
    (position:absolute on .column doesn’t work)

    #105989
    simoncmason
    Member

    Out of interest – what is your use case for this?

    It seems you are using a table layout and then trying to force it to something a table layout was never designed to do – I’d be intrigued to see why.

    Position relative kind of works – see this CodePen – but only if you know the spacing and work it out manually so probably no good for what you want.

    #105996
    braaf
    Member

    thanks for your feedback.
    i’m trying to make a variable grid layout , but the top row has only 2 boxes. one left and one right.
    the remaining rows can have different numbers of boxes, and all left aligned.
    come to think of it, maybe I can use table-column-group?

    #106025
    filipeb
    Member

    Would this do what you want?

    http://jsfiddle.net/BeBum/8/

    #106082
    braaf
    Member

    beautiful!
    with the position:absolute I was already halfway, but never would’ve come up with the :first-child :last-child.
    thanks.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘CSS’ is closed to new topics and replies.