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.html > Horizontal CSS list, last entry right-aligned?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Horizontal CSS list, last entry right-aligned?

Réponse
 
LinkBack Outils de la discussion
Vieux 11/04/2008, 20h01   #1
vulpes
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Horizontal CSS list, last entry right-aligned?

Hi,

I have a horizontal css list and I'd like its last item to be aligned
to the right end
of the space given to the list. I can separate it from the rest with
margin-left: 10em, but that's very error-prone (different resolutions)
and
just doesn't look that good.

Using align: right doesn't work. Using float: right almost works.
The item is then right-aligned, but it's not in the list anymore but
one
line under it.

Anyone with an answer?
  Réponse avec citation
Vieux 11/04/2008, 20h06   #2
Jonathan N. Little
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Horizontal CSS list, last entry right-aligned?

vulpes wrote:
> Hi,
>
> I have a horizontal css list and I'd like its last item to be aligned
> to the right end
> of the space given to the list. I can separate it from the rest with
> margin-left: 10em, but that's very error-prone (different resolutions)
> and
> just doesn't look that good.
>
> Using align: right doesn't work. Using float: right almost works.
> The item is then right-aligned, but it's not in the list anymore but
> one
> line under it.
>
> Anyone with an answer?


URL to what you are trying....

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
  Réponse avec citation
Vieux 11/04/2008, 20h18   #3
vulpes
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Horizontal CSS list, last entry right-aligned?

> URL to what you are trying....

.... is (or better said a minimal example)

http://www.cis.hut.fi/ntvuok/tmp/index.html
  Réponse avec citation
Vieux 11/04/2008, 21h42   #4
Jonathan N. Little
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Horizontal CSS list, last entry right-aligned?

vulpes wrote:
>> URL to what you are trying....

>
> ... is (or better said a minimal example)
>
> http://www.cis.hut.fi/ntvuok/tmp/index.html


Not perfect, works in gecko and Opera. IE7 needs a tweak for your
border. Fails in IE6 but so does your original. Your attempt at XHTML
isn't ing if you wan IE on board...reasons much discussed here...

#navlist {
background: #eee;
position: relative;
border-top: #ffa500 1px solid;
border-bottom: #ffa500 1px solid;
overflow: hidden; /* <- Add to contain floats */
}

#navlist li {
display: block; /* <- make floats to left */
float: left;
}

#navlist li > a {
color: black;
text-decoration: none;
padding: 0 1em 0 1em;
}

#navlist li.current > a {
background: #ddd;
}

#navlist li > a:hover, #navlist li > a:focus {
background: #d1e5fd;
}

#navlist li#rightAlign {
float: right; /* <- make last float to right */
}


--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
  Réponse avec citation
Vieux 11/04/2008, 21h58   #5
vulpes
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Horizontal CSS list, last entry right-aligned?

Wow, many thanks to you!
I'll probably look at IE compatibility later on. The
site'll be non-commercial so as far as I care IE users
can burn, but others in the team might have other
opinions...
  Réponse avec citation
Vieux 13/04/2008, 18h30   #6
vulpes
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Horizontal CSS list, last entry right-aligned?

Actually I now found an even better solution myself. The problem with
Jonathan's solution was that it then eventually prevented any submenus
from showing. The following solutions works around this and should
be quite usable across browsers:

#navlist {
background: #eee;
position: relative;
border-top: #ffa500 1px solid;
border-bottom: #ffa500 1px solid;
}

#navlist li {
display: inline; /* Make list horizontal */
list-style-type: none;
}

#navlist li > a {
color: black;
text-decoration: none;
padding: 0 1em 0 1em; /* Make entries 'airy' */
}

#navlist li.current > a {
background: #ddd;
}

#navlist li > a:hover, #navlist li > a:focus {
background: #d1e5fd;
}

#navlist li#rightAlign {
position: absolute;
right: 0; /* Fit the entry right next to the end. */
}



/* Don't show any submenus for pages that don't have submenus. */
#navlist ul {
display: none;
}

/* The current submenu is shown. */
ul#currentSubnav {
display: block;
font-size: 90%;
position: absolute; /* Fit the submenu to the left border */
left: 0;
right: 0; /* Make the submenu span the whole width */
background: #ddd;
border-top: #ffa500 1px solid;
border-bottom: #ffa500 1px solid;
}

ul#currentSubnav li.current > a {
background: #bbb;
}

ul#currentSubnav li > a:hover, ul#currentSubnav li > a:focus {
background: #fde5d1;
}
  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 12h31.


Édité par : vBulletin® version 3.7.3
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 ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,14096 seconds with 14 queries