473,383 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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?
Jun 27 '08 #1
7 7795
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
Jun 27 '08 #2
URL to what you are trying....

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

http://www.cis.hut.fi/ntvuok/tmp/index.html
Jun 27 '08 #3
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 helping 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
Jun 27 '08 #4
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...
Jun 27 '08 #5
In article
<13**********************************@a9g2000prl.g ooglegroups.com>,
vulpes <ni*********@tkk.fiwrote:
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?
Float right inline can be made to work if the rightmost item actually
comes first in the list. It is taken out of the flow. There were some
positioning issues with Firefox.

See experiment http://ericlindsay.com/palmtop/palmnote.htm

--
http://www.ericlindsay.com
Jun 27 '08 #6
In article
<NO***********************************@freenews.ii net.net.au>,
Eric Lindsay <NO*************@ericlindsay.comwrote:
Float right inline can be made to work if the rightmost item actually
comes first in the list. It is taken out of the flow. There were some
positioning issues with Firefox.

See experiment http://ericlindsay.com/palmtop/palmnote.htm
Yes, there is a difference with FF. Mentioned in these ngs from time to
time. Perhaps also see:

<http://netweaver.com.au/floatHouse/page5.html>

There are links to some appendices on this and, there, find further
links to screenshots for different browsers.

BTW, floats are always "taken out of the flow".

--
dorayme
Jun 27 '08 #7
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;
}
Jun 27 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: ciwstudy | last post by:
I'm having problems getting the height to compress for a horizontal list in IE (styled with CSS). It works fine in other browsers. Does anyone know a way to fix this? ...
2
by: PC | last post by:
Hi, I have used the DLast("!","")function to find and display the last entry in a table. How would I go about displaying the last record in a table that is not Null? Thanks in advance ...pc
11
by: David Messner | last post by:
Ok I know this is simple but the statement eludes me... I have a date field where I want the default value on the data entry form's date field to be the last date entered. I figure I can do this...
5
by: John Veldthuis | last post by:
My code works perfectly 100% when adding items to my ArrayList and updating the listbox. Works perfectly when deleting an item in the ArrayList when it is not the last entry but if it is the last...
8
by: Nathan | last post by:
I am trying to prevent a horizontal list from wrapping. Each list item is floated with "float: left". Currently I use an ugly hack. I set the width of the list to a large number which is...
9
by: Verona Busch | last post by:
Hi everybody, I am very happy to find this group. I am searching for a solution to make a horizontal list menu with submenu on hover. I found a lot of examples for horizontal lists which open...
1
by: irq3 | last post by:
I want to make a horizontal list elements, whose widths are determined by their "width" property. "width" doesn't work on inline elements, so I can't use <spanas I normally would if the width was...
1
by: Sakakini | last post by:
How can I append last entry from one table to another table???
5
by: Wernerh | last post by:
Hi, I have created a log in a listbox to show users everytime someone has logged on. Is there a form load function that will scroll down the listbox to the last entry each time the form is loaded?? ...
1
by: Fuzz13 | last post by:
I have 2 fields that will be inserted into my database ip address and datetime. Each time they are entered they are assigned a ScanID primary key so the value should increment with each entry. How do...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.