473,651 Members | 2,582 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Please, help me vertically fit text into an inner DIV

Hello experts,

I need some help to do in a proper way what I am doing. I have some
"cells" in a web page. Each "cell" is made of 2 DIV. One is inside the
other.
Example with 2 "cells" :

<div class=c7bg style="top:202p x;left:585px;wi dth:55px;height :30px;">
<div class=c7fg style="top:7px; left:2px;">
<table><tr>
<td width=49px height=14px valign=middle>S HIPVIA</td>
</tr>
</table>
</div>
</div>
<div class=c6bg style="top:202p x;left:643px;wi dth:80px;height :30px;">
<div class=c6fg style="top:7px; left:2px;">
<table><tr>
<td width=74px height=14px valign=middle>E MPLOYEEID</td>
</tr>
</table>
</div>
</div>
where these are the styles

<style type="text/css" media="screen">

..c6bg{position :absolute;backg round:#B8860B;b order-width:1px;borde r-style:outset;}
..c6fg{position :absolute;borde r-width:0;color:# FFFFFF;backgrou nd:transparent; text-align:center;fo nt-family:Tahoma;f ont-size:11px;font-weight:bold;}
..c7bg{position :absolute;backg round:#DAA520;b order-width:1px;borde r-style:outset;}
..c7fg{position :absolute;borde r-width:0;color:# FFFFFF;backgrou nd:transparent; text-align:center;fo nt-family:Tahoma;f ont-size:11px;font-weight:bold;}

</style>

The outer DIV represents the "background " of the cell, while the
inner (with background:tran sparent) represents
the "foreground ".
The foreground needs to be sometimes vertically centered
(valign=middle) . Some other times it needs to be Top or Bottom. I did
that using a <TABLE>.

** Question ***

I feel I am not doing this right. In particular I would like to get
rid of that ridiculous table thingy

<table><tr>
<td ... valign=middle>t ext</td>
</tr>
</table>

and still to be able to vertically center/top/bottom the text.

How can transform this poor code in some nice CSS? I need actual code
suggestions which work with Firefox and IE, at least. Thanks

If you see other things that are wrong please do advise.

-P

Sep 7 '06 #1
0 2316

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

Similar topics

19
5731
by: George Ziniewicz | last post by:
.. I try to use CSS when possible, though I am still learning and don't maximize its use. In particular, I still use a table to provide for a centered image in a few slideshows (though table vertical align doesn't work in Mozilla): http://zintel.com/homepics.html I've used combinations of <center>, style align 'center', table cell align, valign and height='100%' to get what I want, but I wonder if CSS can do it by itself.
1
1764
by: Vancer | last post by:
I am having trouble vertically positioning text in a simple table layout using background css images. I need the Page1 , Page2 text to be vertically centred within the table cell. See the source code for the embedded styles. Please visit: http://www.theinternetgolfclub.com/css.html
27
9239
by: FL | last post by:
Hi Everyone, I know howto center a block using margin-left: auto ; margin-right: auto ; but I'm trying to center vertically a box, any idea to solve this?
10
26868
by: john T | last post by:
Is there anyway to vertically center a html table using css in such a way it does not alter the html table. When I tryied it just screws up.
8
5105
by: Terry | last post by:
Trying my hand at table-less design. Looking for an XHTML 1.0 strict, CSS2 compliant solution. Here's the result I'm looking for: Div I: Some header text DIV II: Some text and a form which should be vertically centered Div III: Rest of content DIV II is the one I cannot resolve. It should span the whole page width, no matter the size of its content. 'Text A' should be aligned to the left, 'Form B' should be aligned to the right but...
5
1723
by: Jean Christophe Avard | last post by:
Hi! I have a query that INNER JOIN's three other tables. All the relation are 1 to 1, except for one, where an Item can have more than one price. I have this query that work fine in MSDE Query Analyzer, but when I fill a dataset with it, I get an error. (I attached a screenshot of it) visual basic code:------------------------------------------------------------------------------
3
4553
by: vtashore | last post by:
I downloaded Steve Leban's RTF2 control and it works as advertised. Good news! After reading reference material on the RTF standard codes, I have been able to write update queries to universally change the font or font size directly in my table without having to edit the text natively in Leban's control. Also good news. I see that there is an RTF code, \posyc, which would center the text vertically within the reference frame. The...
4
4437
by: avi | last post by:
Hello, I am trying to vertically center text in a background image, I found a solution on this site that sets the line-height to the height of the background image. This works just fine, except when the text is too long that it wraps. div.module h2{ width:178px; width:"182px"; height:28px; font-family:"Avenir Black", verdana, geneva, sans-serif; background:url(../images/nav_subhead_bg.gif) repeat;
1
5633
by: Maxime | last post by:
Hello, I want to make a button that automatically resizes according to the text length and the font size (which can be changed in firefox pretty easily with the browser). The button already works for resizing horizontally, the problem is when I enlarge the text using firefox, the text doesnt stay aligned with the button. If the text is larger, the text is not centered vertically in the button.
0
8347
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8275
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,...
1
8457
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
7294
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
6157
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
5605
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
4280
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2696
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1585
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.