PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.info.authoring.CSS > Is it possible to vertical align in a div?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Is it possible to vertical align in a div?

Réponse
 
LinkBack Outils de la discussion
Vieux 17/03/2008, 17h46   #1
Dave Rado
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Is it possible to vertical align in a div?

Hi

See my mock-up at http://tinyurl.com/35tv29. The three icons are
supposed to be vertically aligned on their bottoms (using "vertical-
align: bottom"), but they aren't, they're vertically aligned on their
tops. Is there any way to align them vertically on their bottoms (or
middle for that matter) short of resorting to using a table (where
"vertical-align: bottom" does work)?

Dave
  Réponse avec citation
Vieux 17/03/2008, 18h09   #2
Ben C
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Is it possible to vertical align in a div?

On 2008-03-17, Dave Rado <dave.rado@dsl.pipex.com> wrote:
> Hi
>
> See my mock-up at http://tinyurl.com/35tv29. The three icons are
> supposed to be vertically aligned on their bottoms (using "vertical-
> align: bottom"), but they aren't, they're vertically aligned on their
> tops. Is there any way to align them vertically on their bottoms (or
> middle for that matter) short of resorting to using a table (where
> "vertical-align: bottom" does work)?


Vertical-align doesn't apply to blocks (like divs).

But you can set it on the imgs inside the divs if you want. Or set img
to display: block which I think is more appropriate here.
  Réponse avec citation
Vieux 18/03/2008, 15h32   #3
Dave Rado
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Is it possible to vertical align in a div?

Hi Ben

On 17 Mar, 17:09, Ben C <spams...@spam.eggs> wrote:

> Vertical-align doesn't apply to blocks (like divs).
>
> But you can set it on the imgs inside the divs if you want.


I tried your suggestion but must be doing something wrong. See my mock-
up at http://tinyurl.com/2qh2vy. Can you see what I'm doing wrong?


> Or set img
> to display: block which I think is more appropriate here.


I tried this suggestion as well but again, I must be doing something
wrong. See my mock-up at http://tinyurl.com/2rzobt. Can you see what
I'm doing wrong?

Perhaps I should explain that I am trying hard to understand the more
complex parts of css but am finding it a real culture shock, having
learnt my html in the early 90x, when everyone used tables, and then
moved away from web development for several years, and I am now having
to build a complex website and as I say am finding the change from
using tables for layout to using css a real culture shock and a huge
learning curve. I don't need convincing of the benefits of the change,
but I need lots of hand holding.

Dave
  Réponse avec citation
Vieux 18/03/2008, 15h36   #4
Dave Rado
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Is it possible to vertical align in a div?

Hi dorayme

On 17 Mar, 22:14, dorayme <doraymeRidT...@optusnet.com.au> wrote:

> Perhaps you can develop from this idea, instead of your html:
>
> <div><img src="../images/Icons/AcrobatSmall.gif" border="0"
> height="100" width="21"></div>
>
> <div><img src="../images/Icons/Bookmark.gif" border="0"
> height="50" width="28"></div>
>
> <div><img src="../images/Icons/Key.jpg" border="0" height="250"
> width="26"></div>
>
> (I have exaggerated your img heights for demo purposes)
>
> And for css, nothing complicated at all, like:
>
> div {display: inline; margin:5%}


I tried your suggestion but must be doing something wrong - see my
mock-up at http://tinyurl.com/2pjwwy. Can you see what I'm doing
wrong? Also, I can't see anything in your code that specifies the
horizontal postions of the three icons. They need to have the exact
horizontal positions that were specified in my original mock-up at
http://tinyurl.com/35tv29.

See also my note to Ben C about my relative lack of expertise and need
for hand-holding.

Dave
  Réponse avec citation
Vieux 18/03/2008, 19h32   #5
Ben C
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Is it possible to vertical align in a div?

On 2008-03-18, Dave Rado <dave.rado@dsl.pipex.com> wrote:
> Hi Ben
>
> On 17 Mar, 17:09, Ben C <spams...@spam.eggs> wrote:
>
>> Vertical-align doesn't apply to blocks (like divs).
>>
>> But you can set it on the imgs inside the divs if you want.

>
> I tried your suggestion but must be doing something wrong. See my mock-
> up at http://tinyurl.com/2qh2vy. Can you see what I'm doing wrong?
>
>
>> Or set img
>> to display: block which I think is more appropriate here.

>
> I tried this suggestion as well but again, I must be doing something
> wrong. See my mock-up at http://tinyurl.com/2rzobt. Can you see what
> I'm doing wrong?


You've got three different divs, two of which are absolutely positioned.

Vertical-align on the images is only going to align them if they're on
the same line, which means (at least) all in the same block box.

> Perhaps I should explain that I am trying hard to understand the more
> complex parts of css but am finding it a real culture shock, having
> learnt my html in the early 90x, when everyone used tables, and then
> moved away from web development for several years, and I am now having
> to build a complex website and as I say am finding the change from
> using tables for layout to using css a real culture shock and a huge
> learning curve. I don't need convincing of the benefits of the change,
> but I need lots of hand holding.


Best to say exactly what you are trying to do with the three images in
the first place from the top.
  Réponse avec citation
Vieux 18/03/2008, 23h41   #6
Dave Rado
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Is it possible to vertical align in a div?

HI Ben

On 18 Mar, 18:32, Ben C <spams...@spam.eggs> wrote:

> Best to say exactly what you are trying to do with the three images in
> the first place from the top.


I'm not sure what information you're asking for. I need to create a
div 607px wide that is horizontally centred on the page, which I've
managed to do successfully. Within this div I need to place three
icons, one at the left edge of the div, one at the right edge of the
div, and one centred within the div. I've also managed to do this
successfully, and I' posted a mock-up (which is at http://tinyurl.com/35tv29)
showing my code which did this. However, the three icons are top-
aligned within the div and top-aligned relative to each other, whereas
I need them to be bottom-aligned - something that is a breeze to do if
one uses tables for layout, but I can't work out how to do it if one
uses divs instead of tables. I was hoping someone would look at the
code in my mock-up and tell me what modifications to make to my code
in order that the three icons would appear in exactly the same
horizontal position as before, but bottom-aligned relative to each
other. I'm not sure what other information I could provide that is
relevant. Can you ?

Dave
  Réponse avec citation
Vieux 18/03/2008, 23h59   #7
Bergamot
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Is it possible to vertical align in a div?

Dave Rado wrote:
>
> I need to create a
> div 607px wide that is horizontally centred on the page, which I've
> managed to do successfully. Within this div I need to place three
> icons, one at the left edge of the div, one at the right edge of the
> div, and one centred within the div. I've also managed to do this
> successfully, and I' posted a mock-up (which is at http://tinyurl.com/35tv29)
> showing my code which did this. However, the three icons are top-
> aligned within the div and top-aligned relative to each other, whereas
> I need them to be bottom-aligned


They really only appear to be top aligned because the line heights are
stretched as needed to fit the inline image. Baseline is the default
alignment for images. If the line heights were equal, the baseline would
be the same for all and they'd be aligned as you want.

Except maybe in IE. It doesn't do well with changing line-height of
replaced elements.

--
Berg
  Réponse avec citation
Vieux 19/03/2008, 00h20   #8
Dave Rado
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Is it possible to vertical align in a div?

HI Berg

On 18 Mar, 22:59, Bergamot <berga...@visi.com> wrote:

> They really only appear to be top aligned because the line heights are
> stretched as needed to fit the inline image. Baseline is the default
> alignment for images. If the line heights were equal, the baseline would
> be the same for all and they'd be aligned as you want.
>
> Except maybe in IE. It doesn't do well with changing line-height of
> replaced elements.


It sounds like I should go back to using tables?

Dave
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 20h58.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,13919 seconds with 16 queries