backgroundcolor not rendered with Netscape, Firefox

Discussion in 'ASP .Net' started by André, Jun 18, 2008.

  1. André

    André Guest

    Hi,

    i created a table with cells. One cell has background-color (LightSlateGray)
    and contains a label without text but also with a backgroundcolor (red). The
    width of the label is set by a value which represents a percentage of
    another value (doesn't matter).

    In IE, it works: i see the background of the cell and the red background of
    the label.
    In Netscape, Safari, Firefox, i only see the backgroundcolor of the cell
    (LightSlateGray) but not the red background of the label.

    Any idea how to solve this?
    Thanks
    André

    Here the source of the file sent to the browser:
    ---------------------------------------------

    <td align="left" style="background-color:LightSlateGray;"><span
    style="display:inline-block;background-color:Red;width:50px;"></span></td>

    And here the code-behind:
    --------------------------
    c = New TableCell
    c.HorizontalAlign = HorizontalAlign.Left
    c.BackColor = Drawing.Color.LightSlateGray
    l = New Label
    l.BackColor = Drawing.Color.Red
    If aantalantw(j) > 0 Then
    l.Width = Math.Round((va(j, k) / aantalantw(j)) * 100, 1)
    Else
    l.Width = 0
    End If
    c.Controls.Add(l)
     
    André, Jun 18, 2008
    #1
    1. Advertising

  2. André wrote:
    > Hi,
    >
    > i created a table with cells. One cell has background-color (LightSlateGray)
    > and contains a label without text but also with a backgroundcolor (red). The
    > width of the label is set by a value which represents a percentage of
    > another value (doesn't matter).
    >
    > In IE, it works: i see the background of the cell and the red background of
    > the label.
    > In Netscape, Safari, Firefox, i only see the backgroundcolor of the cell
    > (LightSlateGray) but not the red background of the label.
    >
    > Any idea how to solve this?
    > Thanks
    > André
    >
    > Here the source of the file sent to the browser:
    > ---------------------------------------------
    >
    > <td align="left" style="background-color:LightSlateGray;"><span
    > style="display:inline-block;background-color:Red;width:50px;"></span></td>
    >
    > And here the code-behind:
    > --------------------------
    > c = New TableCell
    > c.HorizontalAlign = HorizontalAlign.Left
    > c.BackColor = Drawing.Color.LightSlateGray
    > l = New Label
    > l.BackColor = Drawing.Color.Red
    > If aantalantw(j) > 0 Then
    > l.Width = Math.Round((va(j, k) / aantalantw(j)) * 100, 1)
    > Else
    > l.Width = 0
    > End If
    > c.Controls.Add(l)
    >


    The display value inline-block is part of the CSS 2.1 standard, so it's
    not implemented in all current browsers. The implementation in IE7 is
    only partial, and Firefox 2 doesn't support it at all.

    As Firefox doesn't recognise the inline-block setting, the span is still
    an inline element. You can't specify a width for inline elements, so as
    there isn't anything in the span, it will not take up any space. The
    background color works just fine, you just don't see it.

    --
    Göran Andersson
    _____
    http://www.guffa.com
     
    Göran Andersson, Jun 18, 2008
    #2
    1. Advertising

  3. André

    André Guest

    Thanks for replying.
    Do you mean there is no solution for this problem?


    "Göran Andersson" <> schreef in bericht
    news:...
    > André wrote:
    >> Hi,
    >>
    >> i created a table with cells. One cell has background-color
    >> (LightSlateGray) and contains a label without text but also with a
    >> backgroundcolor (red). The width of the label is set by a value which
    >> represents a percentage of another value (doesn't matter).
    >>
    >> In IE, it works: i see the background of the cell and the red background
    >> of the label.
    >> In Netscape, Safari, Firefox, i only see the backgroundcolor of the cell
    >> (LightSlateGray) but not the red background of the label.
    >>
    >> Any idea how to solve this?
    >> Thanks
    >> André
    >>
    >> Here the source of the file sent to the browser:
    >> ---------------------------------------------
    >>
    >> <td align="left" style="background-color:LightSlateGray;"><span
    >> style="display:inline-block;background-color:Red;width:50px;"></span></td>
    >>
    >> And here the code-behind:
    >> --------------------------
    >> c = New TableCell
    >> c.HorizontalAlign = HorizontalAlign.Left
    >> c.BackColor = Drawing.Color.LightSlateGray
    >> l = New Label
    >> l.BackColor = Drawing.Color.Red
    >> If aantalantw(j) > 0 Then
    >> l.Width = Math.Round((va(j, k) / aantalantw(j)) * 100, 1)
    >> Else
    >> l.Width = 0
    >> End If
    >> c.Controls.Add(l)
    >>

    >
    > The display value inline-block is part of the CSS 2.1 standard, so it's
    > not implemented in all current browsers. The implementation in IE7 is only
    > partial, and Firefox 2 doesn't support it at all.
    >
    > As Firefox doesn't recognise the inline-block setting, the span is still
    > an inline element. You can't specify a width for inline elements, so as
    > there isn't anything in the span, it will not take up any space. The
    > background color works just fine, you just don't see it.
    >
    > --
    > Göran Andersson
    > _____
    > http://www.guffa.com
     
    André, Jun 19, 2008
    #3
  4. André

    marss Guest

    On Jun 19, 12:28 pm, "André" <> wrote:
    > Thanks for replying.
    > Do you mean there is no solution for this problem?
    >
    > "Göran Andersson" <> schreef in berichtnews:...
    >
    > > André wrote:
    > >> Hi,

    >
    > >> i created a table with cells. One cell has background-color
    > >> (LightSlateGray) and contains a label without text but also with a
    > >> backgroundcolor (red). The width of the label is set by a value which
    > >> represents a percentage of another value (doesn't matter).

    >
    > >> In IE, it works: i see the background of the cell and the red background
    > >> of the label.
    > >> In Netscape, Safari, Firefox, i only see the backgroundcolor of the cell
    > >> (LightSlateGray) but not the red background of the label.

    >
    > >> Any idea how to solve this?
    > >> Thanks
    > >> André

    >
    > >> Here the source of the file sent to the browser:
    > >> ---------------------------------------------

    >
    > >> <td align="left" style="background-color:LightSlateGray;"><span
    > >> style="display:inline-block;background-color:Red;width:50px;"></span></td>

    >
    > >> And here the code-behind:
    > >> --------------------------
    > >> c = New TableCell
    > >> c.HorizontalAlign = HorizontalAlign.Left
    > >> c.BackColor = Drawing.Color.LightSlateGray
    > >> l = New Label
    > >> l.BackColor = Drawing.Color.Red
    > >> If aantalantw(j) > 0 Then
    > >> l.Width = Math.Round((va(j, k) / aantalantw(j)) * 100, 1)
    > >> Else
    > >> l.Width = 0
    > >> End If
    > >> c.Controls.Add(l)

    >
    > > The display value inline-block is part of the CSS 2.1 standard, so it's
    > > not implemented in all current browsers. The implementation in IE7 is only
    > > partial, and Firefox 2 doesn't support it at all.

    >
    > > As Firefox doesn't recognise the inline-block setting, the span is still
    > > an inline element. You can't specify a width for inline elements, so as
    > > there isn't anything in the span, it will not take up any space. The
    > > background color works just fine, you just don't see it.

    >
    > > --
    > > Göran Andersson
    > > _____
    > >http://www.guffa.com


    If the label is the only element within the cell then just set the
    label's display property to "block".
    If there are several elements than use "display:block" together with
    "float:left" (or "float:right")

    Label l = new Label()
    l.Style["display"] = "block";
    l.Style["float"] = "left"; //optional

    Code in C#, I do not remember VB syntax :(

    Mykola
    http://marss.co.ua
     
    marss, Jun 19, 2008
    #4
  5. André

    André Guest

    Thanks

    "marss" <> schreef in bericht
    news:...
    On Jun 19, 12:28 pm, "André" <> wrote:
    > Thanks for replying.
    > Do you mean there is no solution for this problem?
    >
    > "Göran Andersson" <> schreef in
    > berichtnews:...
    >
    > > André wrote:
    > >> Hi,

    >
    > >> i created a table with cells. One cell has background-color
    > >> (LightSlateGray) and contains a label without text but also with a
    > >> backgroundcolor (red). The width of the label is set by a value which
    > >> represents a percentage of another value (doesn't matter).

    >
    > >> In IE, it works: i see the background of the cell and the red
    > >> background
    > >> of the label.
    > >> In Netscape, Safari, Firefox, i only see the backgroundcolor of the
    > >> cell
    > >> (LightSlateGray) but not the red background of the label.

    >
    > >> Any idea how to solve this?
    > >> Thanks
    > >> André

    >
    > >> Here the source of the file sent to the browser:
    > >> ---------------------------------------------

    >
    > >> <td align="left" style="background-color:LightSlateGray;"><span
    > >> style="display:inline-block;background-color:Red;width:50px;"></span></td>

    >
    > >> And here the code-behind:
    > >> --------------------------
    > >> c = New TableCell
    > >> c.HorizontalAlign = HorizontalAlign.Left
    > >> c.BackColor = Drawing.Color.LightSlateGray
    > >> l = New Label
    > >> l.BackColor = Drawing.Color.Red
    > >> If aantalantw(j) > 0 Then
    > >> l.Width = Math.Round((va(j, k) / aantalantw(j)) * 100, 1)
    > >> Else
    > >> l.Width = 0
    > >> End If
    > >> c.Controls.Add(l)

    >
    > > The display value inline-block is part of the CSS 2.1 standard, so it's
    > > not implemented in all current browsers. The implementation in IE7 is
    > > only
    > > partial, and Firefox 2 doesn't support it at all.

    >
    > > As Firefox doesn't recognise the inline-block setting, the span is still
    > > an inline element. You can't specify a width for inline elements, so as
    > > there isn't anything in the span, it will not take up any space. The
    > > background color works just fine, you just don't see it.

    >
    > > --
    > > Göran Andersson
    > > _____
    > >http://www.guffa.com


    If the label is the only element within the cell then just set the
    label's display property to "block".
    If there are several elements than use "display:block" together with
    "float:left" (or "float:right")

    Label l = new Label()
    l.Style["display"] = "block";
    l.Style["float"] = "left"; //optional

    Code in C#, I do not remember VB syntax :(

    Mykola
    http://marss.co.ua
     
    André, Jun 19, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. LeftHorn
    Replies:
    11
    Views:
    1,127
    Blinky the Shark
    Apr 1, 2006
  2. Cliff Cotterill

    DropDownList BackgroundColor not set

    Cliff Cotterill, Nov 15, 2007, in forum: ASP .Net
    Replies:
    10
    Views:
    772
    Juan T. Llibre
    Nov 16, 2007
  3. Philip

    default style.backgroundColor value

    Philip, Sep 19, 2003, in forum: Javascript
    Replies:
    1
    Views:
    117
  4. RobG

    backgroundColor and Firefox

    RobG, Nov 3, 2004, in forum: Javascript
    Replies:
    1
    Views:
    117
    Thomas 'PointedEars' Lahn
    Dec 12, 2004
  5. cosmic foo

    backgroundColor

    cosmic foo, Jul 24, 2005, in forum: Javascript
    Replies:
    13
    Views:
    216
    Richard Cornford
    Jul 25, 2005
Loading...

Share This Page