473,761 Members | 2,410 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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

....
<tr style="height:4 0">
...
<td colspan="1" rowspan="2" align="left" valign="top"
style="overflow :hidden;">
...contents.exp lained.later...
</td>
...
</tr>
<tr style="height:1 36">
...
</tr>
....

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

<div style="width:94 px; height:106px; vertical-align:middle;
text-align:center">< img src="...not.imp ortant.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 8455
Ka************* @gmx.net (Kai Grossjohann) wrote:
I have a table which contains a top-aligned table cell:

<tr style="height:4 0">
You're missing the units. Is that 40 nanometers or 40 lightyears?
<td colspan="1" rowspan="2" align="left" valign="top"
style="overflo w:hidden;">
...contents.exp lained.later...
</td>
...
</tr>
<tr style="height:1 36">
...
</tr>
...

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

<div style="width:94 px; height:106px; vertical-align:middle;
text-align:center">< img src="...not.imp ortant.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.infosystem s.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
5304
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 <div>s have a different background color. The side bar <div> extends partly down the page while the main content area <div> goes almost all the way down. The problem I am having is in getting the side bar's background to line up with the main...
3
5012
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 height:auto) the larger div doesn't seem to see the nested divs, and they spill out the bottom. IE seems to automatically resize the larger div as long as I set the height to 100% or any pixel size. Mozilla doesn't recognize the percent, and...
7
4229
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 defined in CSS file. Forzing a drawing refresh by minimizing and restoring browser window or by overlapping another window on browser causes
14
14975
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
4855
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 runat=server and give it an id so I can find it from the code-behind, but after that I want to add the <div>. One problem I see is that I just add the <div> to the <body>, all of the other controls (including the aspx <form>) will not be inside it. What...
3
3812
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" onclick="__doPostBack('SitesRadioButtonList_3','')" language="javascript" />
4
5556
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
2967
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 background-color to the div, the color won't fill up the entire space I believe it should. The div only has color around the text though it has one line space to the above element. I hope it is clear what I mean:
28
5371
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 </p>s included as well. <P>aaaaaaaaa</p><DIV>bbbbbbbbb</DIV><DIV>cccccccc<P>dddddddd</p></DIV>
5
5266
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 see what I am after as these browsers work fine. However, in FF the results are slightly different - take a look and you'll see that the <p>, within <div class="mainContent"> has shot way over to the right. I've been working on this for 2days now...
0
9345
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9957
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9905
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9775
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8780
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7332
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6609
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5229
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5373
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.