I've even run into more clearing issues (though not important to my current design, so I'm still cool for now)! Still need to get these under my belt though for future reference.
So, I've implemented your version of definition lists. It's very nice. I did run into a little strangeness when I had 2 dd's for one dt. I ended up doing this (which I think will only work when the total widths of the two dd's together does not exceed the available space for any single dd)
(code changed for clarity)
Code:
<div>
<h3>Thing 1</h3>
<dl>
<dt>Something:</dt>
<dd>Yes it exists</dd>
<dt>Something:</dt>
<dd>Yes it exists</dd>
<dt>Something:</dt>
<dd>No</dd>
<dt>Something:</dt>
<dd>Yes it exists</dd>
<dt>Something:</dt>
<dd>Yes it exists</dd>
<dt>Something:</dt>
<dd>Yes it exists</dd>
<dt>Something:</dt>
<dd>Nope</dd>
<dt>Something:</dt>
<dd>Yes it exists</dd>
</dl>
</div>
<div id="extra" class="clear">
<h3>Extra costs (in €)</h3>
<dl>
<dt>Something:</dt>
<dd class="wider">Explanation</dd>
<dt>Something:</dt>
<dd>30 <dd>per week</dd></dd>
<dt>Something:</dt>
<dd>40 <dd>per day</dd></dd>
<dt>Something:</dt>
<dd>Not available<dd>-</dd></dd>
<dt>Something:</dt>
<dd>Not available <dd>-</dd></dd>
<dt>Something:</dt>
<dd>30 <dd>per day, per person</dd></dd>
<dt>Toeristenbelasting:</dt>
<dd>0 <dd>-</dd></dd>
<dt>Extra bed:</dt>
<dd>present <dd>per day</dd></dd>
<dt>Deposit:</dt>
<dd class="wider">200,00</dd>
</dl>
</div>
Code:
(divs are floated too to carry h3's and h4's)
dl {
width: 30.5em;
float: left;
font-size: 1em;
overflow: hidden;
background-color: #0f0;<-- for testing
}
dl dt {
font-weight: bold;
float: left;
width: 11.5em;
padding: 0 0 .5em .2em;
background-color: #f00;<--testing
clear: both;
}
dl dd {
width: 16em;
float: left;
padding: .2em;
background-color: #ff0;<--testing
border: 1px solid #000;<--testing
}
(didn't want to stick this in the HTML for certain reasons)
* html dl dd {float: none;}
*+html dl dd {float: none;}
#extra dd {
margin-right: 1em;
background-color: #00f;<--testing
width: 6em;
white-space: nowrap; <--wanted to stop some wrapping
float: left;
}
#extra dd.wider {
width: 16em; <--first dd in this list doesn't have a partner, stops float wrapping
}
I might have done it the long way, but it seems stable and works cross browser. I should have thought this was a possibility in the beginning. Because of the way the code is written, I've needed to add " - " for when the person filling out the form didn't choose anything (is a drop-down menu), because there now MUST be either a second nested dd OR the "wider" class to make sure it takes up enough room. I needed the float to apply to everyone, even IE.
Also only works when there in fact are no borders or background colours. The nested dd pops out of it's container (what I want) except in IE6 where it wraps the container... the net result looks the same when you can't see the container.
Still, I would think this would work for anyone else doing the same.
Bookmarks