views:

2137

answers:

6

Hi,

I'm trying to create a "workflow" bar on a web page.

The items in the workflow might be of different lengths.

There might be enough items to fill the width of the screen, hence the flow needs to wrap onto the next line.

I'm using left floating divs to do this.

However, I'd like the divs to take an appropriate amount of screen width.

If only three items can fit on one line, then I'd like those items to fit evenly on the line, taking into account each individual items width.

All I can get at the moment is for the final div on a line to fill up the remaining space, which often means my items are all left aligned, e.g. I can get a layout like this:

AAAA -> BBBBB ->
CCCCCCCCCCCCCCCCCCC -> DD -> EEE ->
FFFFF -> GGGG -> HHHHH

but I actually want it to look something like this:

      AAAA   ->   BBBBB  ->
CCCCCCCCCCCCCCCCCCC  -> DD -> EEE ->
   FFFFF ->  GGGG ->  HHHHH

if you see what I mean.

Please does anyone have any ideas? I'm pulling my hair out on this, but CSS isn't my strongest point.

Do I need to use tables for this rather than floating divs?

Thanks.

+1  A: 

could probably do with seeing the surrounding markup to understand what elements you have in place. You could try having a surrounding div with margin: 0 auto;

You're probably going to need a surrounding div for each level.

John Polling
A: 

Don't waste your time just go here:

http://www.cssmenubuilder.com/build-breadcrumb-menu

DrG
A: 

Thanks for the prompt responses. I'll try out what you are suggesting.

I'm currently trying to do this using a list, although I also got nowhere with divs.

I've tried pulling some HTML of my JSPs in order to try and demonstrate where I'm up to with this.

The spans have a class of "navigation" which basically draws a background image around the text to make it look like a button, as well as setting margins/paddings/etc. I've omitted the CSS which is directly related to the button drawing, since this is standard framework stuff in our system to draw a button. I have included the CSS which I'm using which is directly related to the workflow.

I'm trying to draw a starting image before the first button and then draw background images behind each button in order to draw a line between each button to represent the flow. I've then got an ending image at the end of the flow.

<html>
<body>

<STYLE>
#nav, #nav ul {
    list-style: none;
    margin: 0px;
    width: 700px;
}

#nav li {
    list-style: none;
    float: left;
    padding-left: 10px;
    padding-right: 10px;
    width: auto;
    background-image: url(/lookandfeel/images/navMenuDiv.gif);
    background-repeat: repeat-x;
}

li#ending {
    background-image: url(/lookandfeel/images/navMenuRight.gif);
    background-repeat: no-repeat;
}

li#start {
    background-image: url(/lookandfeel/images/navMenuLeft.gif);
    background-repeat: no-repeat;
}

.navigation a {
  background-image: url(/pdr/images/navigation.gif);
}
</STYLE>

<ul id="nav" style="width: 100%;border: 1px solid">
  <li id="start" />
  <LI >
    <SPAN class="navigation" >AAAAAAAAAA</SPAN>
  </li>
  <LI >
     <SPAN class=navigation >BBBB</SPAN>
  </li>
  <LI >
    <SPAN class=navigation>CCCCCCCCCCCCCCCCC</SPAN>
  </li>
  <LI>
    <SPAN class=navigation>DDDDDDDDD</SPAN>
  </li>
  <LI>
    <SPAN class=navigation>EEEEEEEE</SPAN>
  </li>
  <LI>
    <SPAN class=navigation>FFFFFFFFFFFFFF</SPAN>
  </li>
  <li>
    <SPAN class=navigation>GGGGGGGGGGGGGGGGGGGGGGGGGGGGG</SPAN
  </LI>
  <li id="ending" />
  </ul>
</body>
</html>
A_M
A: 

Setting the li elements to display: inline, and giving the ul a text-align: justify property will get you part way there (in FFX3 and IE7 at least). However, it does raise some complications when applying the background images.

AaronSieb
+1  A: 

just a couple of other pointers. You should not have empty li tags, that is not semantically correct. Also in an ideal world you should [not give id attributes layout names].[1]

Personally I'd place the starting image on the ul and then place the closing image on the last li.

John Polling
A: 

As much as I dislike to say things can't be done, I think I have to agree with @johnners on the surrounding element for each navigation level. Even if you were to use table layout CSS you would need some sort of surrounding element for each 'row' in order to get the spacing on the left and right correct.

Bryan