Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / CSS / August 2006



Tip: Looking for answers? Try searching our database.

horizontal list of elements with specified widths

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
irq3 - 31 Aug 2006 02:10 GMT
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 <span> as I normally would if the width was determined by
content.

I played around with float: left, display: block, position: absolute,
trying to get them to work properly and I've had some level of success,
but I'm looking for some advice from the gurus on how to do this
properly.

I really wish that I could just apply a width to an inline <span>. What
technique comes the closest to this behavior and is there a page
demonstrating the various techniques?

thanks
-irq3
Chris F.A. Johnson - 31 Aug 2006 02:37 GMT
> 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 <span> as I normally would if the width was determined by
> content.

  Use a block element such as <p>, or <li>.

> I played around with float: left, display: block, position: absolute,
> trying to get them to work properly and I've had some level of success,
[quoted text clipped - 4 lines]
> technique comes the closest to this behavior and is there a page
> demonstrating the various techniques?

  Do you want something like this:

<style>
ul {
list-style-type: none;
}

ul li,p {
float: left;
width: 5em;
border: 1px solid #cccccc; /* to show width */
text-align: center;
}

h3 { clear: both; }
</style>

<ul>
  <li>first</li>
  <li>second</li>
  <li>third</li>
  <li>fourth</li>
  <li>fifth</li>
</ul>

<h3>Or this:</h3>

<p>one
<p>two
<p>three
<p>four
<p>five

 You can see the above example at:
 <http://cfaj.freeshell.org/testing/list.html>

 Or a real-world page: <http://cfaj.freeshell.org/xword/S017.html>

Signature

  Chris F.A. Johnson                      <http://cfaj.freeshell.org>
  ===================================================================
  Author:
  Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.