468,768 Members | 1,715 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,768 developers. It's quick & easy.

Table link cells work but text forced to top alignment


CSS

Description:
Table contains a column of td cells with links.

Achieved:
1. Entire link cells highlight when hovered.
2. The entire area of these cells are clickable.

Problem:
As these cells expand heightwise to accomodate text in other cells
along the same row;
the link text is forced to the top of the cell.
(only noticeable in the expanded cells, of course, but the text is
obviously positioned this way in all of them.)

Removing the "height="100%" from the "td a" style solves the vertical
alignment problem,
however, it destroys the highlighting and clickability of the upper and
lower portions of these cells.

So, the "height=100%" has to stay, but I wonder, how do I get the link
text to vertically align in the middle,
i.e. override being forced to the top.

Current stylesheet - (you will only see the problem if you make a table
with a non-link td cell on the same row, and fill it with a lot of text
until it expands heightwise):

td {
height: 1px;
}

td a {
border-left: 1px solid #FFFFFF;
color: #0000ff;
background-color: #ffffff;
display:block;
width: 100%;
text-decoration: none;
}

td a:visited {
border-left: 1px solid #FFFFFF;
color: #ff00ff;
background-color: #ffffff;
}

td a:hover {
border-left: 1px solid #FFFFFF;
color: #ffffff;
background-color: #0000ff;
}

Jul 21 '05 #1
5 4515
Don't forget to place "height: 100%" in the "td a" section!

Jul 21 '05 #2
DU
Harry wrote:
CSS

Description:
Table contains a column of td cells with links.

Achieved:
1. Entire link cells highlight when hovered.
2. The entire area of these cells are clickable.

Problem:
As these cells expand heightwise
Your CSS code has specifically and explicitly given a total height: 1px;
constraint on such cell. Aren't you creating yourself the problem?

to accomodate text in other cells along the same row;
A table row will always take the height necessary to render the highest
cell; if it was not the case, then tables would not make content accessible.
the link text is forced to the top of the cell.
I guess you mean that there is a reflow somehow.
(only noticeable in the expanded cells, of course, but the text is
obviously positioned this way in all of them.)

Removing the "height="100%" from the "td a" style solves the vertical
alignment problem,
You css declaration was saying take exactly 100% of 1px to render that
block-level anchor.
however, it destroys the highlighting and clickability of the upper and
lower portions of these cells.
Whenever you have a layout problem, alignment, position, reflow, redraw
issues, then best is to post an url and identify the browsers and
browser versions having such problem.

So, the "height=100%" has to stay,
You describe the consequences of your css code (without understand it
IMO), then you experiment with it and then you conclude your code has to
be kept.

but I wonder, how do I get the link text to vertically align in the middle,
i.e. override being forced to the top.

Personally, I do not remember ever resorting to height: 100%; or height:
any value; for any table component or for a table itself because 99% of
the time, you end up constraining the layout of a table, you try to go
against normal flow of browser instead of using it. It's like risking or
asking an elephant to get into the driver seat of a car and askign the
elephant not to modify the car's height or roof.
Current stylesheet - (you will only see the problem if you make a table
with a non-link td cell on the same row, and fill it with a lot of text
until it expands heightwise):

td {
height: 1px;
}

td a {
border-left: 1px solid #FFFFFF;
color: #0000ff;
background-color: #ffffff;
display:block;
width: 100%;
Useless, IMO, and typical of an over-constraining coding policy on table.
text-decoration: none;
}

td a:visited {
border-left: 1px solid #FFFFFF;
color: #ff00ff;
background-color: #ffffff;
}

td a:hover {
border-left: 1px solid #FFFFFF;
color: #ffffff;
background-color: #0000ff;
}


DU
--
The site said to use Internet Explorer 5 or better... so I switched to
Mozilla 1.7.6 :)
Jul 21 '05 #3

DU wrote:

Your CSS code has specifically and explicitly given a total height: 1px; constraint on such cell. Aren't you creating yourself the problem?

I know what you mean, but it was the only way I could devise to expand
the hover change to effect the entire height of the cell.
A table row will always take the height necessary to render the highest cell; if it was not the case, then tables would not make content accessible.

That, I do know, but I don't know what is forcing to link text up
against the top of the cell. I can't get it to vertically align in the
middle.

Removing the "height="100%" from the "td a" style solves the vertical alignment problem,


You css declaration was saying take exactly 100% of 1px to render

that block-level anchor.
however, it destroys the highlighting and clickability of the upper and lower portions of these cells.
Whenever you have a layout problem, alignment, position, reflow,

redraw issues, then best is to post an url and identify the browsers and
browser versions having such problem.

So, the "height=100%" has to stay,
You describe the consequences of your css code (without understand it

IMO), then you experiment with it and then you conclude your code has to be kept.
You're right that I have a limited understanding of css. I am certainly
struggling with it (and the variety of browser compatibility is also
adding to the confusion!)

As far as saying that I have to keep that snippet of code, what I am
saying specifically here is that, if I remove it, the same thing
happens as above - I lose covering the entire td cell with the link.
(Somehow, and I'm sure you will tell me I am showing my ignorance, I
have only been successful so far by having both the "td height: 1px"
and "td a height:100%" in the stylesheet.

(My thinking with the first one was that I had to define a cell height.
Then, I thought I can't make it more than the 1px or it would expand
the height of all the td link cells - and thereby the rows, and the
table as a whole.)

<>you try to go
against normal flow of browser instead of using it. <>


I gotcha. But then how do you explain that to someone who tells you
they don't want their table any taller than it already is?

Thanks for your feedback.
Harry.

Jul 21 '05 #4
Here's the url:

http://rs485.ca/css/table.html

Jul 21 '05 #5
Using IE 6
(Firefox renders completely differently.

Jul 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

31 posts views Thread by Royal Denning | last post: by
1 post views Thread by cotton_gear | last post: by
1 post views Thread by Thanks | last post: by
7 posts views Thread by Shawn B. | last post: by
7 posts views Thread by Jef Driesen | last post: by
7 posts views Thread by Kamal | last post: by
dmjpro
3 posts views Thread by dmjpro | last post: by
5 posts views Thread by jrod11 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.