text position

P

Paul Udstrand

hello,

I'm recently updating my web pages, and I have a glitch in my index page.
There are a series of small pictures running down the middle of the page,
next to these photos, I have text such as "weddings", "Portraits" etc. My
problem is that the text is aligned on bottom of the associated photo, I'd
like it to be up in the middle.

Any help would be appreciated.

Paul.
 
E

Els

Paul said:
hello,

I'm recently updating my web pages, and I have a glitch in
my index page. There are a series of small pictures
running down the middle of the page, next to these photos,
I have text such as "weddings", "Portraits" etc. My
problem is that the text is aligned on bottom of the
associated photo, I'd like it to be up in the middle.

Any help would be appreciated.

add
img{vertical-align:middle;}
to your styles
 
N

Neal

hello,

I'm recently updating my web pages, and I have a glitch in my index page.
There are a series of small pictures running down the middle of the page,
next to these photos, I have text such as "weddings", "Portraits" etc.
My
problem is that the text is aligned on bottom of the associated photo,
I'd
like it to be up in the middle.

Any help would be appreciated.

Paul.


There are many ways to do this. Perhaps the easiest is to do this:

CSS:
..foo {position: relative;}

..caption {margin: auto; position: relative; bottom: 40px}

HTML:
<div class="foo">
<img height="100" width="100">
<span class="caption">Weddings</span>
</div>

The container's position: relative makes it the containing block. The
other one offsets the caption. A little less than half the height of the
image should be fine, but adjust as desired.

Note that if the text will be resizable, there's no way to know how many
pixels high the text will be on the user's screen, so it won't be
perfectly centered. But it'll be close.
 
E

Els

Neal said:
I like this better. Yay Els.

LOL

I first read this, didn't get what you were on about, then
read your other reply. Haven't dived into it, but boy, does
that look complicated <g>
 
N

Neal

I first read this, didn't get what you were on about, then
read your other reply. Haven't dived into it, but boy, does
that look complicated <g>

Not really too complicated, but it goes around the corner to do what yours
does more elegantly and more accurately.
 
P

Paul Udstrand

add
img{vertical-align:middle;}
to your styles

I tried adding this, but got no where. I guess I don't know precisely
where to add it. I'm really clueless.

I tried the css method as well, but got no better results, for the same
reason.

Thanks for trying.
 
N

Neal

I tried adding this, but got no where. I guess I don't know precisely
where to add it. I'm really clueless.

I tried the css method as well, but got no better results, for the same
reason.

Thanks for trying.


I tested my idea and Els' idea, here's how I did it.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Center Test</title>
<style type="text/css">
..foo {position: relative;}
..caption {position: relative; bottom: 40px}
..foo2 img {vertical-align: middle;}
</style>
</head>
<body>
<div class="foo">
<img height="100" width="100">
<span class="caption">Weddings</span>
</div>
<div class="foo2">
<img height="100" width="100">
<span class="caption2">Weddings</span>
</div>
</body>
</html>

In practice, the styles would be an external stylesheet. If this at all
confuses you, see http://www.w3schools.com and go through the CSS tutorial.
 

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,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top