tags:

views:

84

answers:

1

This is my code for a nice looking form:

<dl>
    <dt class='breed'><label for="nwberichten">Fieldname</label></dt>
    <dd>
     Input
    </dd>
    <div class='clear'>&nbsp;</div>
</dl>
<dl class='oe'>
        <dt class='breed'><label for="nwberichten">Fieldname</label></dt>
        <dd>
         Input
        </dd>
        <div class='clear'>&nbsp;</div>
    </dl>

With the folowing CSS

dl {margin-top:0px;}
dt {float:left; text-align:right; width:120px; line-height:25px; margin:0 10px 10px 0;}
dd {float:left; width:400px; line-height:25px; margin:0 0 10px 0;}
DL  {
    border-bottom:1px dashed #aaa;
    margin:0px;
    line-height:20px;
    padding-top:6px;;
}

DL DD   {
    line-height:20px;
    background:transparent;
}
DT  {
    line-height:20px;
    background:transparent;
}
DL.oe   {
    background:#efe;
}

In webkit (eg Safari) the Uneven row, the one with the BG color #efe looks perfect. The bgcolor goes from one dashed border to the other. In IE the color is only 10px (or so) high and the looks are messed up.

How is this possible?

+1  A: 

I'll briefly explain what I did and why. The code is at the end.

The first mistake is using clearing divs inside the dl element. A dl can only contain dds and dts. To achieve clearing you can set overflow to hidden for your dls. It achieves the same effect. This is also probably why your page looks a bit messed up in IE (because of the divs in the dls)

As for the rest, I just cleaned up your CSS a bit.

HTML:

<dl>
    <dt class="breed"><label for="nwberichten">Fieldname</label></dt>
    <dd>
     Input
    </dd>
</dl>
<dl class="oe">
    <dt class="breed"><label for="nwberichten">Fieldname</label></dt>
    <dd>
        Input
    </dd>
</dl>

CSS:

dl { margin:0; padding-top:6px; overflow:hidden; border-bottom:1px dashed #aaa; }
dl.oe { background:#efe; }
dt, dd { float:left; line-height:25px; background:transparent; }
dt { text-align:right; width:120px; margin:0 10px 10px 0;}
dd { width:400px; margin:0 0 10px 0;}
Darko Z
Thank you DarkoZ! I didn't know a div is not allowed within a DL....
blub