CSS Div Width Problem - Lining divs... widths seem to be off in IE7

Posted by jlrolin on Stack Overflow See other posts from Stack Overflow or by jlrolin
Published on 2010-03-22T18:49:30Z Indexed on 2010/03/22 18:51 UTC
Read the original article Hit count: 516

Filed under:
|
|
|

So far, I'm doing this programmatically using VB.net/ASP.net:

    'Create Container Div
    Dim ContainerDiv As New HtmlGenericControl("div")
    ContainerDiv.Style("width") = "100%"
    ContainerDiv.Style("clear") = "both"
    ContainerDiv.Style("text-align") = "left"
    ContainerDiv.Style("margin") = "0"

    'Create Expand/Collapse Image
    Dim img As New Image
    img.ImageUrl = Page.ResolveUrl("~/images/minus99.jpg")
    img.Attributes.Add("onclick", "change(this.parent);")

    'Create Company Display
    Dim lbl As New Label
    lbl.Text = Parsetext(pc.NAME)
    lbl.Font.Bold = True
    lbl.Style("font-size") = "16px"

    Dim NameDiv As New HtmlGenericControl("div")
    'NameDiv.Style("background-color") = "#F0D3D3"
    NameDiv.Style("width") = "375px"
    NameDiv.Style("float") = "left"
    NameDiv.Style("margin") = "0"
    NameDiv.Style("display") = "block"
    NameDiv.Controls.Add(img)
    NameDiv.Controls.Add(lbl)
    ContainerDiv.Controls.Add(NameDiv)

    Dim SetupDiv As New HtmlGenericControl("div")
    SetupDiv.Style("background-color") = "#F0D3D3"
    SetupDiv.Style("width") = "210px"
    SetupDiv.Style("float") = "left"
    SetupDiv.Style("margin") = "0"
    SetupDiv.Style("display") = "block"
    'SetupDiv.Style("position") = "fixed"
    ContainerDiv.Controls.Add(SetupDiv)

    Dim UsedDiv As New HtmlGenericControl("div")
    UsedDiv.Style("background-color") = "#CFF5CE"
    UsedDiv.Style("width") = "140px"
    UsedDiv.Style("float") = "left"
    UsedDiv.Style("margin") = "0"
    UsedDiv.Style("display") = "block"
    'UsedDiv.Style("position") = "fixed"
    ContainerDiv.Controls.Add(UsedDiv)

    Dim RemDiv As New HtmlGenericControl("div")
    RemDiv.Style("background-color") = "#BEE0F7"
    'RemDiv.Style("position") = "absolute"
    RemDiv.Style("width") = "210px"
    RemDiv.Style("float") = "right"
    RemDiv.Style("padding") = "0"
    RemDiv.Style("margin") = "0"
    RemDiv.Style("display") = "block"
    'RemDiv.Style("position") = "fixed"
    ContainerDiv.Controls.Add(RemDiv)

This should give me four DIVS inside a container DIV. Here's what it's coming out as:

alt text

The correct blocks above the non-inline blocks are from a table with the same exact widths as the ones I'm using on the Divs. There isn't any CSS adding pixels to them, I don't think. I need to line these up, and I can't figure out where my problem is here. Any help would be appreciated.

© Stack Overflow or respective owner

Related posts about css-positioning

Related posts about css