473,509 Members | 2,880 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Bottom-aligned text in a fixed-height DIV

Hi,

I'm currently encountering a problem with vertical alignment of text in
a DIV that drives me mad.

I'm having a DIV with a fixed height (say 50px) which contains some text
from which I don't know if it will be rendered in one line or two.

But that text should absolutely be bottom-aligned since the space
between the bottom border-line and the text must always be the same and
the bottom border-line must always be at the same vertical position, no
matter if the text is rendered as one line or two lines.

I need a similar behaviour as with <td valign="bottom"> table cells.

Some ASCII art for further explanation (monospaced font useful):

---------------------- ^ -------------
| | | | |
| | fixed | |
| | height | two-line |
| one-line text | | | text |
====================== V ============= <- border bottom-line

Currently I'm using:

<div class="chapter">Some text</div>

with

div.chapter {
position: relative;
top: 40px;
float: left;
height: 50px;
width: 320px;
margin: 0 0 0 20px;
padding: 0;
text-align: left;
vertical-align: bottom;
font-size: 40px;
font-weight: bold;
border-bottom: 7px #7080C0 solid;
}

which produces a real mess, when the text in the DIV wraps.

Can anyone help me?

Thanks,

Michael


Jul 21 '05 #1
3 48405
Michael Goldbach wrote:
Hi,

I'm currently encountering a problem with vertical alignment of text in
a DIV that drives me mad.

I'm having a DIV with a fixed height (say 50px) which contains some text
from which I don't know if it will be rendered in one line or two.

<snip>

How about this approach? Change the line height of the .clear div to
vary the amount of space that appears above the text.

<style type="text/css">
..chapter {
position: relative;
top: 40px;
float: left;
height: 50px;
width: 320px;
margin: 0 0 0 20px;
padding: 0px;
text-align: left;
vertical-align: bottom;
font-size: 40px;
font-weight: bold;
border-bottom: 7px #7080C0 solid;
background-color: #FFAABB;
}
..clear{
clear: all;
font-size: 15px;
}
</style>
</head>

<body>
<div class="chapter">
<div class="clear">&nbsp;</div>
Large Amount of Text (line wrap)</div>
<br>
<br>
<div class="chapter">
<div class="clear">&nbsp;</div>
Small Amt Txt</div>
</body>
Jul 21 '05 #2
In comp.infosystems.www.authoring.stylesheets Michael Goldbach said:
I'm currently encountering a problem with vertical alignment of text in
a DIV that drives me mad.
I'm having a DIV with a fixed height (say 50px) which contains some text
from which I don't know if it will be rendered in one line or two.


div{height:50px;position:relative;}
p{bottom:0;position:absolute;}

<div>
<p>some text</p>
</div>
--
the facts and opinions expressed by brucies
l i t t l e v o i c e s
are not necessarily the same as those held by brucie.
Jul 21 '05 #3

brucie wrote:
div{height:50px;position:relative;}
p{bottom:0;position:absolute;}

<div>
<p>some text</p>
</div>


Yeah, that's it! It works. You're my saviour.

Bye,

Michael

Jul 21 '05 #4

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

Similar topics

82
10593
by: Peter Diedrich | last post by:
The site design is pretty simple: ============================================ | Head | ============================================ | | ...
4
2643
by: Christopher | last post by:
This should be a quick one. URL: http://cfa-www.harvard.edu/~cpilman/Stuff/flush.html Code: ============================= <!DOCTYPE HTML Public "-//W3C//DTD HTML 4.01//EN">...
1
3928
by: Tony Benham | last post by:
Hi, I've been trying for a while, but I still haven't worked out a way of making a footer appear at the bottom of a webpage, and not at the bottom of the browser window ! See...
13
42328
by: Michael Hill | last post by:
I have created a test page with a window in it created by using divs, but I haven't figured out how to move the "down arrow" to the bottom of the main div. http://www.hulenbend.net/test2.html ...
2
6724
by: Gnolen | last post by:
Hi, I want to put a div at the bottom of the screen. Not a fixed div but relative to the height of the overal design and screen size. And it is outside the content div. My thought was simply...
6
6096
by: George Hester | last post by:
I have this DIV at the very bottom of a html. <head> <style type="css/text" media="all"> <!-- #oFoot { position: relative; left: 0px; width: 100%; height: 50px; filter:...
26
2494
by: meltedown | last post by:
I have 2 left floating divs on a page. Sometime the left side is larger, sometimes the right side is larger. I want the page to have a margin at the bottom of whichever div is the largest. If I...
12
2126
by: S | last post by:
Here's a very basic question. . . I have a DIV that contains content that I need to be bottom-justified. What is the CSS code to do that? Thanks, ---------------S
23
1686
by: Antoon Pardon | last post by:
I know this PEP is rejected. However I have a problem that would benefit from having extreme values and the sample implementation that is given in the PEP is unsatifactory for my purpose. I had...
0
7237
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,...
0
7137
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...
1
7073
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...
0
7506
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...
1
5062
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...
0
4732
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...
0
3218
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...
0
3207
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1571
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 ...

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.