Results 1 to 4 of 4

Thread: display: table... not working on divs

  1. #1
    Join Date
    Jun 2008
    Posts
    192
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Default display: table... not working on divs

    I'm trying to make use of the table style display modes for divs. What I mean by table style display modes is the CSS display values:

    table, table-row, and table-cell.

    What I'd like is essentially 3 rows that span the whole width of the page, and in the second row have two cells at 50% of the page width

    each.

    Here's the code:

    Code:
    <html>
    <head></head>
    <body>
     <div id="MainPageDiv" style="display: table; border: 3px solid black; width: 100%; background-color: orange;">
            <div id="DateTimeDiv" style="background-color: red; width: 100%; display: table-row; column-span: all;">
                top row
            </div>
    
            <div id="ConcernDetailsDiv" style="background-color: blue; padding: 20px; height: 400px; display: table-row; column-span: all;">
    
    	    Middle row
    
                <br />
                <br />
    
                <div id="PatientIncidentDiv" style="background-color: yellow; height: 100px; display: table-cell;">
                    left cell
                </div>
    
                <div id="ReportingPersonDiv" style="background-color: pink; height: 100px; display: table-cell;">
                    right cell
                </div>
    
            </div>
    
            <div id="SubmitButtonDiv" style="background-color: grey; width: 100%; display: table-row; column-span: all;">
                bottom row
            </div>
        </div>
    </body>
    </html>
    This doesn't seem to be working for me however. In the attached image, you can see that 1) the top and bottom rows (red and grey) do not

    span the whole table, and 2) the middle two cells (yellow and pink) don't seem to be contained in the middle row (blue).

    Can anyone help me figure out why it's not working?

  2. #2
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,881
    Thanks
    49
    Thanked 266 Times in 258 Posts
    Blog Entries
    56

    Default

    Do you mean this?
    Code:
    <div id="MainPageDiv" style="display: table; border: 3px solid black; width: 100%; background-color: orange;">
    
    <div id="DateTimeDiv" style="background-color: red; ">top row</div>
    
    <div id="ConcernDetailsDiv" style="background-color: blue; padding: 20px; height: 400px; text-align: center">
    <span style="color: white">Middle row</span><br><br>
    
    <div id="PatientIncidentDiv" style="background-color: yellow; height: 100px; display: inline-block;  width: 50%; margin-left: -5px">left cell</div>
    
    <div id="ReportingPersonDiv" style="background-color: pink; height: 100px; display: inline-block; left: 50%; width: 50%">right cell</div>
    
    </div>
    
    <div id="SubmitButtonDiv" style="background-color: grey; width: 100%; ">bottom row</div>
    
    </div>

  3. #3
    Join Date
    Jun 2008
    Posts
    192
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by molendijk View Post
    Do you mean this?
    Code:
    <div id="MainPageDiv" style="display: table; border: 3px solid black; width: 100%; background-color: orange;">
    
    <div id="DateTimeDiv" style="background-color: red; ">top row</div>
    
    <div id="ConcernDetailsDiv" style="background-color: blue; padding: 20px; height: 400px; text-align: center">
    <span style="color: white">Middle row</span><br><br>
    
    <div id="PatientIncidentDiv" style="background-color: yellow; height: 100px; display: inline-block;  width: 50%; margin-left: -5px">left cell</div>
    
    <div id="ReportingPersonDiv" style="background-color: pink; height: 100px; display: inline-block; left: 50%; width: 50%">right cell</div>
    
    </div>
    
    <div id="SubmitButtonDiv" style="background-color: grey; width: 100%; ">bottom row</div>
    
    </div>
    Yeah, that works. Funny how we have to resort to inline-block when table-row and table-cell are *supposed* to do the same thing. Why is that?

  4. #4
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,881
    Thanks
    49
    Thanked 266 Times in 258 Posts
    Blog Entries
    56

Similar Threads

  1. Chained menu with click action to display hidden divs
    By miradoro in forum Dynamic Drive scripts help
    Replies: 10
    Last Post: 04-10-2018, 04:26 PM
  2. Replies: 0
    Last Post: 10-18-2011, 02:50 PM
  3. XSLT Unique Show/Hide Divs from Table
    By ejeaglesct in forum JavaScript
    Replies: 0
    Last Post: 12-15-2010, 08:40 PM
  4. :focus on divs not working??
    By shachi in forum CSS
    Replies: 8
    Last Post: 08-17-2006, 10:12 PM
  5. Display Divs w/Function problem
    By befab in forum JavaScript
    Replies: 2
    Last Post: 11-02-2005, 06:51 PM

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
  •