vertical-align

W

windandwaves

Hi Folk

Can you do vertical-align bottom in a div or only really in a table? I
prefer to use divs of course, but in tables, the vertical align seems
to be working better. Is this correct?

TIA

Nicolaas
 
B

Ben C

Hi Folk

Can you do vertical-align bottom in a div or only really in a table?

You can set it on inline level elements to move them relative to the
line they're on. But if you want the effect of a box with a set height
that contains another box at the bottom of it, use positioning. Set the
outer box to position: relative (or position: absolute), and the inner
box to position: absolute with bottom: 0px.

You set position on the outer box just to make it the containing block
for the inner box (i.e. the block the inner box is 0px from the bottom
of).

Using relative rather than absolute on the outer box keeps it "in the
normal flow".
 
W

windandwaves

Ben said:
You can set it on inline level elements to move them relative to the
line they're on. But if you want the effect of a box with a set height
that contains another box at the bottom of it, use positioning. Set the
outer box to position: relative (or position: absolute), and the inner
box to position: absolute with bottom: 0px.

You set position on the outer box just to make it the containing block
for the inner box (i.e. the block the inner box is 0px from the bottom
of).

Using relative rather than absolute on the outer box keeps it "in the
normal flow".

Hi, I tested it and it works a treat. THANK YOU

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title></title>
</head>
<body>
<div id="outer" style="position: relative; height: 300px;
background-color: #ccc; width: 200px;">
<div id="inner" style="position: absolute; bottom: 0px;
background-color: #777; ">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Pellentesque leo. Duis
arcu erat, posuere non, fringilla vel, ultricies ut, purus. Nunc
turpis. Nullam
hendrerit, elit nec molestie pellentesque, ligula ante tempor dui, eu
molestie
nibh erat sed sem. Maecenas orci. Donec aliquam imperdiet sapien.
</div>
</div>
</body>
</html>
 
J

Jonathan N. Little

windandwaves said:
I go for xhtml strict, but visual studio from Windoz does not....
Sorry. Thanks again for your help.
What! MS won't let you change your doctype! Or is just a default, and
most don't know how to change it. Don't know Visual Studio, most folks
who use Perl with CGI.pm only use the default "XHTML 1.0 Transitional"
but you *can* change it....


use CGI qw(-no_xhtml);
$CGI::DEFAULT_DTD = ['-//W3C//DTD HTML 4.01//EN',
'http://www.w3.org/TR/html4/strict.dtd'];
 
P

password

ive just done this for a div containing a form (drop down list thing) and it
works fine in ie6 and firefox2 but opera9 leaves a 10 (approx) gap at the
bottom - anyway around this?
i am currently testing my page in all other (browser/op) combinations with
http://browsershots.org/ so may have to return again for more help ho hum.
 
B

Ben C

ive just done this for a div containing a form (drop down list thing) and it
works fine in ie6 and firefox2 but opera9 leaves a 10 (approx) gap at the
bottom - anyway around this?

It's probably just a margin-- try adding margin-bottom: 0 to the form.
 
P

password

Ben C said:
It's probably just a margin-- try adding margin-bottom: 0 to the form.

ah i shall try that.. in my ignorance i thought bottom:0px was refering to
the margin.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top