473,408 Members | 1,861 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,408 software developers and data experts.

100% Horizontal list possible ?

Hi all,

Is it possible to have 4 LI items in a <UL> with the LI width set to
width:25% so that each one sizes to 25% of whatever its container width
is ? It doesnt seem so, the width doesnt seem to affect the li. even
when the ul width is 100%

Any thoughts ?

Dave.
Jul 21 '05 #1
12 9166
Dave Brown wrote:
Hi all,

Is it possible to have 4 LI items in a <UL> with the LI width set to
width:25% so that each one sizes to 25% of whatever its container
width is ? It doesnt seem so, the width doesnt seem to affect the
li. even when the ul width is 100%

Any thoughts ?

Dave.


<style type="text/css">
ul
{
list-style: none;
width: 50%;
}

li
{
float: left;
width: 25%;
}
</style>

<ul>
<li>One</li>
<li>Two</li>
<li>Three</li>
<li>Four</li>
</ul>
Jul 21 '05 #2
in comp.infosystems.www.authoring.stylesheets, Dave Brown wrote:
Hi all,

Is it possible to have 4 LI items in a <UL> with the LI width set to
width:25% so that each one sizes to 25% of whatever its container width
is ? It doesnt seem so, the width doesnt seem to affect the li. even
when the ul width is 100%

Any thoughts ?


URL? What exactly did you do?

--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Jul 21 '05 #3
On Mon, 22 Nov 2004 21:31:12 +0000, Dave Brown <da**@nospamhere.dbws.net>
wrote:
Is it possible to have 4 LI items in a <UL> with the LI width set to
width:25% so that each one sizes to 25% of whatever its container width
is ? It doesnt seem so, the width doesnt seem to affect the li. even
when the ul width is 100%


Sure it is. You need to change li to display: inline; though, otherwise
they go below each other by default.
Jul 21 '05 #4
Nik Coughin wrote:
li
{
float: left;
width: 25%;
}


That works too. ;)
Jul 21 '05 #5
Neal wrote:
Is it possible to have 4 LI items in a <UL> with the LI width set to
width:25%
Sure it is. You need to change li to display: inline;


No, the moment you make them display: inline, the width property no longer
applies. You'll need to use float instead.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 21 '05 #6
Dave Brown wrote:
Hi all,

Is it possible to have 4 LI items in a <UL> with the LI width set to
width:25% so that each one sizes to 25% of whatever its container width
is ? It doesnt seem so, the width doesnt seem to affect the li. even
when the ul width is 100%

Any thoughts ?

Dave.

Thanks for the replys, the thing missing was a float:left; for the li
element. without that it didnt size to 25%. but nowi have to stop the
last one dropping because there is a border, so asking it to be 25% will
make it drop. maybe 24.9% will do ;-)
Jul 21 '05 #7
David Dorward <do*****@yahoo.com> wrote:
Is it possible to have 4 LI items in a <UL> with the LI width set to
width:25%

Sure it is. You need to change li to display: inline;


No, the moment you make them display: inline, the width property no longer
applies. You'll need to use float instead.


In cases like this, before suggesting to float an element it should imo
always be pointed out that the correct way to do this is to set display
to either inline-block or inline-table, and that resorting to floating
is a nasty hack which is sometimes needed because Mozilla and IE don't
support either css value [1].

Then it should be pointed out that using floats inappropriately like
this has drawbacks such as running into UA float bugs, floats being
removed from the flow and the necessity to use the clear property on the
next block level element (with more bugs).

The #1 problem people run into when using css for layouts is due to IE's
lack of support for css tables, the #2 problem is floats being used
inappropriately, the problems they cause which leads to people saying
that css isn't suitable for layouts.

[1] on block level elements

--
Spartanicus
Jul 21 '05 #8
Spartanicus wrote:
The #1 problem people run into when using css for layouts is due to
IE's lack of support for css tables, the #2 problem is floats being
used inappropriately, the problems they cause which leads to people
saying that css isn't suitable for layouts.


After spending a couple of years around ciwas, I'd have to concur that
these are the biggest stumbling blocks in css. In fact, it might be
worth preparing article, perhaps linked to the faq, to warn newcomers
("danger ahead!").

--
Brian (remove "invalid" to email me)
Jul 21 '05 #9
Brian <us*****@julietremblay.com.invalid> wrote:
The #1 problem people run into when using css for layouts is due to
IE's lack of support for css tables, the #2 problem is floats being
used inappropriately, the problems they cause which leads to people
saying that css isn't suitable for layouts.


After spending a couple of years around ciwas, I'd have to concur that
these are the biggest stumbling blocks in css. In fact, it might be
worth preparing article, perhaps linked to the faq, to warn newcomers
("danger ahead!").


IIRC it was Neal who recently concluded that there is not a single good
CSS layout tutorial on the net. I briefly thought about having a go at
one, but I chickened out when I realized how much work it would be to
create something that I myself would be happy with.

I also considered asking the group for volunteers to do something
collectively, but I fear that creating a really good tutorial from a
collective effort would require so much coordination that the required
individual effort would still be huge (for the coordinator at least).

--
Spartanicus
Jul 21 '05 #10
On Tue, 23 Nov 2004 20:39:12 +0000, Spartanicus <me@privacy.net> wrote:
IIRC it was Neal who recently concluded that there is not a single good
CSS layout tutorial on the net.


And there's a cold martini for the first person to prove me wrong. One is
sorely needed. Two would be even better, because we could argue more;)
Jul 21 '05 #11
Spartanicus wrote:
Brian wrote:

The #1 problem people run into when using css for layouts is due
to IE's lack of support for css tables, the #2 problem is floats
being used inappropriately, the problems they cause which leads
to people saying that css isn't suitable for layouts.


After spending a couple of years around ciwas, I'd have to concur
that these are the biggest stumbling blocks in css. In fact, it
might be worth preparing article, perhaps linked to the faq, to
warn newcomers ("danger ahead!").

IIRC it was Neal who recently concluded that there is not a single
good CSS layout tutorial on the net. I briefly thought about having a
go at one, but I chickened out when I realized how much work it would
be to create something that I myself would be happy with.

Yeah, you'll notice that I didn't volunteer myself. ;-) I'll be
moving into a new apartment soon, and plan on getting high speed
internet. Perhaps when I do I'll be able to donate some time to such a
project.

--
Brian (remove "invalid" to email me)
Jul 21 '05 #12
PC

"Spartanicus" <me@privacy.net> wrote in message
news:1s********************************@news.spart anicus.utvinternet.ie...
Brian <us*****@julietremblay.com.invalid> wrote:
IIRC it was Neal who recently concluded that there is not a single good
CSS layout tutorial on the net.


I started out with Webmonkey to learn html simply because that's where I
ended up when doing a search. When I discovered what W3C stood for, and
that the website would teach me much, I completely went through the html
"class" over and over on parts until I could get a perfect score on the
quiz. I then went through the section on CSS, but found it lacking in
exactly "how-to". It assumes I know too much already.

Where would be the best place to learn the deeper things about html/CSS? Is
the W3Cschools site the best place? Is webmonkey up-to-date enough to
depend on for a different perspective?

--
PC
Jul 21 '05 #13

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

Similar topics

1
by: RugbyTravis | last post by:
I want to have a list that is horizontal and each <li> has different images. I also want them to change on hover. I want the words to be below the images as well. Anyone of you styles gurus have...
2
by: Neal | last post by:
Having a bit of trouble. http://users.rcn.com/neal413/horizlisttest.html Because of design restraints, I need to follow a 100% wide header section with a div. The background color of the...
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? ...
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...
1
by: DarthDevilous | last post by:
I've been trying to lay out a list horizontally, like at http://www.w3schools.com/css/tryit.asp?filename=trycss_float5 , but I'm having some problems. The HTML Structure is <div id="page_footer">...
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: nitinpatel1117 | last post by:
i am using an unordered list to display my horizontal navigation. i am using something link <ul> <li>link 1</li> <li>link 2</li> </ul>
10
by: crippletoe | last post by:
Hi all, i am looking for a way to prevent a horizontal, inline unordered list from breaking into seperate lines once contained inside a element with specific width (shorter than the list). the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.