tags:

views:

37

answers:

2

http://jsfiddle.net/F7BTx/

I'm trying to align just some text within a table header cell to the bottom of the cell, but I need the rest of the text to be centered. What's the best way to do this?

Ex desired output:

Header 1 is       Header 2           Header 3
on two lines        

    [-]              [-]                [-]

Current output:

Header 1 is       Header 2           Header 3
on two lines        

                     [-]                [-]
    [-]
+1  A: 

Usually you would use vertical-align: bottom; instead of vertical-align: center;; however this will also bring the Header ns to the bottom as well. There is no way around this, that I am aware of, other than to use two rows for your header. One with ths and one with tds. Vertically align the second row with vertical-align: bottom and the first one with vertical-align: center;

SimpleCoder
"Your question is not easily answered in a good way" is the best solution to this problem, unfortunately :P.
Stefan Kendall
+1  A: 

edit: here you go: http://jsfiddle.net/TKxrC/20/

Try something like this:

<style>
  th.cool_format {
    position:relative; height:64px;
  }
  th.cool_format .table_head_title {
    position:absolute;
  }
  th.cool_format .some_weird_thing {
    position:absolute;
    bottom:0px;
  }
</style>
<th class='cool_format'>
  <span class='table_head_title'> Header 1 is on two lines </span>
  <span class='some_weird_thing'> [-] </span>
</th>

...not tested. If it doesn't work right, try giving th.cool_format a fixed width and the stuff inside of it the same width or widths of 100%. If it still doesn't work replace the spans with divs or make the spans display:block.

no
I tried something similar. It seems you can't use relative positioning for table cells, so you need a dummy `div` inside the `th`.
casablanca
yeah, you do... just realized that myself. I think it's because `th` are not `display:block`.
no
I don't know the heights of the headers. This is dynamic and needs to be re-usable across different table setups.
Stefan Kendall
Here you go, this one doesn't use absolute heights. http://jsfiddle.net/4D6bk/
no
Post that as an answer, no. Either way, it doesn't work in IE or Opera :P. Didn't try chrome.
Stefan Kendall
If it didn't help it's not a very good answer ;) ... actually this can work or not work depending on your doctype; heights in standards mode can be very counterintuitive. Google "doctype height css" or "css table height" or something along those lines and you'll see what I mean. This article looks decent at a glance -- http://apptools.com/examples/tableheight.php
no
There's no way in hell I can get a DOCTYPE change in right now. I'm dealing with a legacy application, and a doctype change (to <!DOCTYPE html>) is at least 2 years away.
Stefan Kendall