472,961 Members | 1,558 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,961 software developers and data experts.

Put vertically centered <div> inside a top-aligned table cell

I have a table which contains a top-aligned table cell:

....
<tr style="height:40">
...
<td colspan="1" rowspan="2" align="left" valign="top"
style="overflow:hidden;">
...contents.explained.later...
</td>
...
</tr>
<tr style="height:136">
...
</tr>
....

Inside that table cell I have a <div> which is centered:

<div style="width:94px; height:106px; vertical-align:middle;
text-align:center"><img src="...not.important.now..." alt="An
image"></div>

The image is less than 94px tall and less than 106px wide, so there
should be some room between the top of the table cell and the top of
the image. But both IE6 and Mozilla 1.4 show the image top-aligned in
the table cell.

I could make more rows with less height such that some of them have a
combined height of 106px, and then put my image in a table cell
spanning just those rows. But for reasons I'm too embarrassed to
expand upon :-) I'd rather avoid making those extra rows.

So can I perhaps replace the div with something else to achieve the
desired effect? I'd like to specify that the image is centered in a
region 106px tall, and that region should be in a table cell 176px
(row of 40px plus row of 136px) tall?

tia,
Kai
Jul 20 '05 #1
1 8415
Ka*************@gmx.net (Kai Grossjohann) wrote:
I have a table which contains a top-aligned table cell:

<tr style="height:40">
You're missing the units. Is that 40 nanometers or 40 lightyears?
<td colspan="1" rowspan="2" align="left" valign="top"
style="overflow:hidden;">
...contents.explained.later...
</td>
...
</tr>
<tr style="height:136">
...
</tr>
...

Inside that table cell I have a <div> which is centered:

<div style="width:94px; height:106px; vertical-align:middle;
text-align:center"><img src="...not.important.now..." alt="An
image"></div>
vertical-align doesn't apply to block level elements. Read the CSS
specs for details.
The image is less than 94px tall and less than 106px wide, so there
should be some room between the top of the table cell and the top of
the image. But both IE6 and Mozilla 1.4 show the image top-aligned in
the table cell.
You've told the browser to align the contents of the cell to the top
with valign=top in your HTML, so that's what the browsers are doing.
So can I perhaps replace the div with something else to achieve the
desired effect? I'd like to specify that the image is centered in a
region 106px tall, and that region should be in a table cell 176px
(row of 40px plus row of 136px) tall?


Do you know the height of the image? If you do then you can align it
by applying margin-top to the image or padding-top to the cell.

Followups set to comp.infosystems.www.authoring.stylesheets

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net> <http://steve.pugh.net/>
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Ben Gribaudo | last post by:
Hello! I am working on revising my Web site template. The main part of the page is divided into two columns (each a <div>)--a side bar on the left and the main content area on the right. Both...
3
by: Philip | last post by:
I am trying to make a bunched of left-floated divs that will be contained in a larger div. the floated divs all contain a left-floated img and text of varying sizes. If I don't set a height (or...
7
by: Dario de Judicibus | last post by:
System: Windows XP SP1 + all latest patches (no SP2) Browser: IE 6.0.2800.1106.xpsp2.040919-1003 Problem: browser does not show, or partially shows, borders and background color of <DIV> as...
14
by: Charlie T | last post by:
Hello, is there any way to get this to work? myID.innerHTML = "Hello" <DIV id="myID"></DIV> <DIV id="myID"></DIV>
8
by: localhost | last post by:
I would like to wrap all of the HTML inside of my <body> tag inside a <div> with in my code-behind. I do not want to touch the .aspx page template at all. I know how to make the body tag...
3
by: Josef K. | last post by:
Asp.net generates the following html when producing RadioButton lists: <td><input id="RadioButtonList_3" type="radio" name="MyRadioButtonList" value="644"...
4
by: Alan Silver | last post by:
Hello, Please pardon what is probably a dumb question, but if I have HTML like this... <div> <h3>Ferrets</h3> </div> and CSS like this...
2
by: Nikolai Onken | last post by:
Hey, I am trying to learn the exact behavior of CSS and was just placing a couple of <div>'s after each other. Each of the <divhas a <pwithin and some text within the <p> Now when I add a...
28
by: Kent Feiler | last post by:
1. Here's some html from a W3C recommendations page. <P>aaaaaaaaa<DIV>bbbbbbbbb</DIV><DIV>cccccccc<P>dddddddd</DIV> 2.Although I didn't think it would make any difference, I tried it with the...
5
nathj
by: nathj | last post by:
Hi All, I'm working on a new site that has a two column layout underneath a title bar. If you check out: http://www.christianleadership.org.uk/scratch/mainpage.php using IE or Opera you will...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.