Vertical align image within a DIV in IE?

P

Paul Lautman

I know that this has been asked many times but I cannot find a definitive
answer to it.

I have the following css and html and I would like to have a couple of
images vertically aligned within the div.

Can anyone point me to a decent incarnation for it?

#header {
float: left;
padding: 0px;
margin-right: 2px;
width: 635px;
height: 150px;
vertical-align: middle;
}

<div id="header">
<img src="images/newbadge2.gif" alt=""/>
</div>

TIA
Paul
 
N

Neredbojias

To further the education of mankind, "Paul Lautman"
I know that this has been asked many times but I cannot find a
definitive answer to it.

I have the following css and html and I would like to have a couple of
images vertically aligned within the div.

Can anyone point me to a decent incarnation for it?

#header {
float: left;
padding: 0px;
margin-right: 2px;
width: 635px;
height: 150px;
vertical-align: middle;
}

<div id="header">
<img src="images/newbadge2.gif" alt=""/>
</div>

TIA
Paul

If you want them dynamically v|aligned, you need a table.

http://www.neredbojias.com/zyxix/vcsc/vcsc.html
 
Y

Yucky Korpulent

If a static image, go ahead and add it to the header css, e.g.

#header {
float: left;
padding: 0px;
margin-right: 2px;
width: 635px;
height: 150px;
background:url(images/newbadge2.gif) no-repeat center;
}

Yucky,
Yukky Korpulent
 
P

Paul Lautman

Yucky said:
If a static image, go ahead and add it to the header css, e.g.

#header {
float: left;
padding: 0px;
margin-right: 2px;
width: 635px;
height: 150px;
background:url(images/newbadge2.gif) no-repeat center;
}

Yucky,
Yukky Korpulent

I need it centered vertically on the left of the block with another image to
the right of it.
 
N

Neredbojias

To further the education of mankind, "Paul Lautman"
The whole template is built with DIVs. I had already tried puting a
table into this particular div but then it totally cocked up the
vertical height of the DIV.

This is a case where a url would have been most helpful. Your reply is
quite illogical.
 
Y

Yucky Korpulent

Opt 1. Use a graphics editor to combine them into a single image

Opt 2. Create style definitions for your images, using relative
positioning to get them where you want. For example,

#imgLeft {
position:relative;
top:40px; /* or whatever */
left:10px; /* etc. */
}
#imgRight {
position:relative;
top:40px; /* or whatever */
left:400px; /* etc. */
}

In this case you are specifying the vertical position yourself rather
than vertical aligning, but since your DIV has specified dimensions
anyway, this should get you want you want. There are ways of using CSS
positioning to achieve true middle vertical alignment for the images
but these can lack cross-browser consistency. Google "css vertical
center div" for tons of examples.

Good luck. Yucky,
Yukky Korpulent
 

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

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top