Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Visibility bug in tables with background-color? (IE6)

  1. #1
    Join Date
    Aug 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Visibility bug in tables with background-color? (IE6)

    I want to blank out various cells of a table (in javascript) using CSS. My table uses alternating background colors for each row. In IE, when I set the visibility property of a cell to hidden, the resulting area appears white, rather than the background color of the row. I'll include a sample of what I mean below. Essentially, I want to see the background color behind cell 1,4. FF displays this correctly (or at least, how I want. :-)

    Thanks for any help y'all can provide...

    nathan

    HTML Code:
    <?xml version="1.0" encoding="iso-8859-1"?>
    <!DOCTYPE html
            PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
             "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
    <head>
    <title>CSS Visibility IE 6.0 Bug</title>
    <style type="text/css">
    tr.header {
      background-color: #CCCC99;
    }
    tr.even {
      background-color: #ECECCC;
    }
    tr.odd {
      background-color: white;
    }
    td.invisibleeven {
      visibility: hidden;
    }
    td.invisibleodd {
      visibility: hidden;
    }
    </style>
    </head>
    <body>
    <h1>CSS Visibility IE 6.0 Bug</h1>
    <h2>Table 1</h2>
    <table>
      <tr class="header"><th>Head 1</th><th>Head 2</th></tr>
      <tr class="odd"><td class="odd">Cell 1,1</td><td class="odd">Cell 2,1</td></tr>
      <tr class="even"><td class="even">Cell 1,2</td><td class="even">Cell 2,2</td></tr>
      <tr class="odd"><td class="invisibleodd">Cell 1,3</td><td class="odd">Cell 2,3</td></tr>
      <tr class="even"><td class="invisibleeven">Cell 1,4</td><td class="even">Cell 2,4</td></tr>
      <tr class="odd"><td class="odd">Cell 1,5</td><td class="odd">Cell 2,5</td></tr>
      <tr class="even"><td class="even">Cell 1,6</td><td class="even">Cell 2,6</td></tr>
    </table>
    </body>
    </html>

  2. #2
    Join Date
    Aug 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    [ Make text color same as background color ]

    Yep, that was my initial solution, but it has a number of issues that lead me to look for an alternative. When the user selects text from that cell, it is revealed because the selection background changes but the text color doesn't (necessarily). Also, if there are other things in the cell (links, for example) these need to be hidden too (for these, visibility: hidden is sufficient). Maybe I could put all text in a span, just for this purpose? Seems like a waste.

    Thanks,

    nathan
    Last edited by nje01; 08-31-2005 at 05:34 PM. Reason: Added context to replace deleted reply...

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I deleted my previous post because it was in error. It does work as you desire in Mozilla with a strict doctype. I hadn't inserted it (the strict doctype) correctly at first. IE still doesn't like it though, even with the strict doctype. So, I guess you have found another browser bug to add to the long list of browser bugs. If you were to supply code or a link to a practical application of this idea, perhaps a more suitable work around could be found.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Here is an IE hack that will not allow selecting of text and gives the desired appearance:
    Code:
    td.invisibleeven {
      visibility: hidden;
    }
    * html td.invisibleeven {
      visibility: visible;
      background-color: #ECECCC;
      color: #ECECCC;
    }
    and:
    HTML Code:
    <td class="invisibleeven" onselectstart="return false;">
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Does it do the same for display:none;?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  6. #6
    Join Date
    Aug 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Well, the practical application is as follows. I have a large table of data (think Excel). I have implemeted sorting and column moving in DHTML / Javascript. Where rows of data have the same values, from the left up to a certain column, I want to make the duplicate values vanish to help the eye discern duplicate values as a grouping. My example, with values to illustrate this application:

    HTML Code:
    <?xml version="1.0" encoding="iso-8859-1"?>
    <!DOCTYPE html
            PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
             "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
    <head>
    <title>CSS Visibility IE 6.0 Bug</title>
    <style type="text/css">
    tr.header {
      background-color: #CCCC99;
    }
    tr.even {
      background-color: #ECECCC;
    }
    tr.odd {
      background-color: white;
    }
    td.invisibleeven {
      visibility: hidden;
    }
    td.invisibleodd {
      visibility: hidden;
    }
    </style>
    </head>
    <body>
    <h1>CSS Visibility IE 6.0 Bug</h1>
    <h2>Table 1</h2>
    <table>
      <tr class="header"><th>Head 1</th><th>Head 2</th></tr>
      <tr class="odd"><td class="odd">Tree</td><td class="odd">Green</td></tr
    >
      <tr class="even"><td class="even">Car</td><td class="even">Green</td><
    /tr>
      <tr class="odd"><td class="invisibleodd">Car</td><td class="odd">Blue</td></tr>
      <tr class="even"><td class="invisibleeven">Car</td><td class="even">Red</td></tr>
      <tr class="odd"><td class="odd">House</td><td class="odd">Brown</td></tr
    >
      <tr class="even"><td class="even">Sky</td><td class="even">Blue</td><
    /tr>
    </table>
    </body>
    </html>
    Cheers!

    nathan

  7. #7
    Join Date
    Aug 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Twey
    Does it do the same for display:none;?
    display: none shifts the cells in column 2 to the left into column 1 (as it should). So, no dice.

  8. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Yes, I was just wondering if it made any difference to the cell's background colour (the empty space on the end of the row, I suppose).
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  9. #9
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Code:
    <style type="text/css">
    tr.header {
      background-color: #CCCC99;
    }
    tr.even {
      background-color: #ECECCC;
    }
    tr.odd {
      background-color: white;
    }
    td.invisibleeven {
      visibility: hidden;
    }
    * html td.invisibleeven {
      visibility: visible;
      background-color: #ECECCC;
      color: #ECECCC;
    }
    td.invisibleodd {
      visibility: hidden;
    }
    </style>
    <script type="text/javascript">
    function ieHide(){
    var tds=document.all.tags('td')
    for (var i = 0; i < tds.length; i++)
    if (tds(i).className=='invisibleeven')
    tds(i).innerHTML='&nbsp;'
    }
    if (document.all&&!window.opera)
    onload=ieHide;
    </script>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  10. #10
    Join Date
    Aug 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    ...which assumes that the contents of the cell can be clobbered and this only need be done on page load. As I said, this is part of a dynamic display in which the sort order of the rows and the order of the columns can be changed - so the logic of which cells to "hide" needs to done dynamically and reversably.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •