problem with relative positioning and table cell height

Discussion in 'CSS' started by bonecone, Sep 27, 2011.

  1. #1
    See screenshot attached.

    I want to set up a table so that error messages appear directly above specific table columns in the form of a div tag with a red background and the same width as the column.

    To do this I've added a div tag inside the <th> element of the table, with the display property set to 'none'.

    
    <th>
       <nobr>Header Content</nobr>
       <div id="error_message">Error Message</div>
    </th>
    
    Code (markup):
    When I want to display an error message above the table I use the following styles on the div tag

    
          background-color: #ffcccc;
          width: 100%;
          position: relative;
          left: 0px;
          top: -100px;
          z-index: 1;
          display: block;
    
    Code (markup):
    It displays the div tag above the header like I want, but it still stretches the height of the <th> element as if it was still contained inside of it. How do I do this without stretching the cell height?
     

    Attached Files:

    • shot.jpg
      shot.jpg
      File size:
      13.2 KB
      Views:
      130
    bonecone, Sep 27, 2011 IP
  2. workingsmart

    workingsmart Well-Known Member

    Messages:
    411
    Likes Received:
    12
    Best Answers:
    9
    Trophy Points:
    120
    #2
    remove => display: block; <= This will take the full "block" out and since there is no specified height, you can add some padding for spacing.
     
    workingsmart, Sep 30, 2011 IP