tags:

views:

1890

answers:

9

I have a mockup layout for something here. Essentially there are sections, columns and fields, which are all written as a combination of <ul> and <li> elements. This is done specifically for later parsing.

A snippet of the HTML:

<li class="layout"><span class="type">[Column] </span>
    <ul class="layout-children">
     <li class="field"><span class="type">[Text] </span>A field</li>
     <li class="field"><span class="type">[Text] </span>Another field</li>
     <li class="field"><span class="type">[Text] </span>Yet another field</li>
    </ul>
</li>
<li class="layout"><span class="type">[Column] </span>
    <ul class="layout-children">
     <li class="field"><span class="type">[Text] </span>More fields</li>
     <li class="field"><span class="type">[Text] </span>And one more field</li>
    </ul>
</li>

If you go to the linked content you'll note that those columns sit vertically. I want the columns to sit beside each other, but I am not sure how to go about it.

It would be preferable if the HTML didn't change, just the CSS.

+3  A: 

In your <UL> tag use the css attribute "list-style:none;" and in the <li> tag use the css attribute "display:inline;" you'll have to play around with the padding and margin to make it look good, but those two attributes will get you on your way. For a better example see my Non-Profit website: Technically Learning

Joe Basirico
A: 

How about this:

.layout { float: left; width: 50%; margin: 0; border: 0; padding: 0; /* background: transparent */ }
* html .layout { display: inline } /* IE margin hack */
.field { clear: both }
Dimitry Z
there are ways to deal with this without the hack, so I would not suggest it.
Ben Scheirman
A: 

yeah using display:block it would be impossible to make them sit beside each other unless if you'd try to specify a width for each of them but if that's the case just use display:inline

lock
+1  A: 

I just added this to your css:

ul .section-children li.layout {
    display : inline-block;
}

Unfortunately, I don't know how well supported inline-block is nodwadays.

Kris
inline-block is definitely the way to go, if it works on the systems you're targeting.
Domenic
inline-block is not supported in IE6 and I don't think it is in IE7, either....
Eric Wendelin
inline-block is certainly supported by both IE 6 and 7... on inline elements.
eyelidlessness
It's not, however, supported by Firefox < 3. Which is why my answer included -moz-inline-box.
eyelidlessness
+4  A: 
display: -moz-inline-box;
display: inline-block;
eyelidlessness
This answer is better than my answer (that got accepted)
Kris
+2  A: 

Excellent resource:

http://css.maxdesign.com.au/listamatic/

ckarbass
A: 

Just an alternative to using inline elements since IE has had a history of padding problems with inline:

.layout-children:after
{
  content: "";
  display: block;
  height: 0px;
  clear: both;
}

.layout-children .field
{
  float: left;
}
Zurahn
IE also has a history of problems with :after pseudo-elements.
eyelidlessness
A: 

Using inline or inline-block is going to be nothing but trouble. It's a much better idea to use floats as @Dmitry Z has suggested (but without the margin hack, which isn't necessary).

Herb Caudill
A: 

A simple float: left will work (with a minor adjustment for the width)

li {
 margin: .5em 1em;
 padding: .1em;

 font-family: sans-serif;
 list-style-type: none;
 border: 1px #666 solid;
 float: left;
}
#layout-section {
 width: 85%;
}
Traingamer