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

Thread: Firefox problem with absolutely positioned DIV in TD

  1. #1
    Join Date
    Sep 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Firefox problem with absolutely positioned DIV in TD

    Hello everybody.
    Actually I'm newby to the CSS design world, and I am facing a problem in positioning absolutely DIV within a table cell. My code is just working fine with IE but not with Firefox. here is my code:

    Code:
    <style>
    table#tblwindows{
    	width:440px;
    }
    
    table#tblwindows td{
    	background-color:#f0eded;
    	width:50%;
    	height:150px;
    	vertical-align:top;
    	padding:10px;
    	border: solid 1px #d6d9d5;
    	position:relative;
    }
    
    
    table#tblwindows div.title{
    	font-size:12px;
    	font-weight:bold;
    	text-align:center;
    	color:Green;
    }
    
    table#tblwindows div.more {
    	background: url(Images/document.gif) no-repeat left 2px;
    	position:absolute;
    	bottom:10px;
    	left:10px;
    	text-align:left;
    	padding-left: 12px;
    	padding-bottom: 2px;
    }
    </style>
    
    <table border="0" cellspacing="10" id="tblwindows">
                        <tr>
                            <td>
                                <div class="title">
                                    articles
                                </div>
                                blabla blabla<br />
                                blabla blabla<br />
                                blabla blabla<br />
                                blabla blabla<br />
                                blabla blabla<br />
                                blabla blabla<br />
                                blabla blabla<br />
                                <div class="more">
                                    <a href="#">more</a>
                                </div>
                            </td>
                            <td>
                                <div class="title">
                                    articles
                                </div>
                                blabla blabla<br />
                                blabla blabla<br />
                                blabla blabla<br />
                                blabla blabla<br />
                                blabla blabla<br />
                                blabla blabla<br />
                                blabla blabla<br />
                                <div class="more">
                                    <a href="#">more</a>
                                </div>
                            </td>
                            </tr>
                    </table>
    In IE, the "more" DIV is positioned exactly as supposed within the TD, but in Firefox it seems positionned relatively to the contatiner of the table.
    Any help is appreciated.

  2. #2
    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

    FF is doing it right. td's cannot really be relatively positioned. You need to have a div that is position:relative that contains all the blah blah blah and the div.more absolutely positioned one.
    - John
    ________________________

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

  3. #3
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Usually people think FF is wrong because it appears right in IE (which isn't standards-compliant). But FF is following guidlines here, not IE.
    - Mike

  4. #4
    Join Date
    Sep 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    jscheuer1 and mburt, thanks for your reply.
    IE is really a headache for developers.
    Anyway, I've tried to insert a container DIV in TD but I want this DIV to take the full height of the cell whereas it's as long as the cell content. This leads to awkward looking of adjacent cells. So my question is how to make the inner DIV to take all the client height of the container table cell?

  5. #5
    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

    The markup:

    HTML Code:
    <td><div class="ftd">
    
    Put your td content here
    
    </div></td>
    The style:

    Code:
    .ftd {
    position:relative;
    width:100%;
    height:100%;
    }
    - John
    ________________________

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

  6. #6
    Join Date
    Sep 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    jscheuer1, thanks for the reply.
    But actually I've already tried height:100% and it didn't work.
    Still it's the same layout, the DIV is only as long as the content.
    It may be useful to post my code:

    Style:
    Code:
    table#tblwindows{
    	width:440px;
    }
    
    table#tblwindows td{
    	background-color:#f0eded;
    	width:50%;
    	/*height:150px;*/
    	vertical-align:top;
    	padding:0px;
    	margin:0px;
    	border: solid 1px #d6d9d5;
    }
    
    table#tblwindows div.container{
    	position:relative;
    	height:100%;
    	padding:10px;
    	border: solid 1px blue;
    }
    
    
    table#tblwindows div.title{
    	font-size:12px;
    	font-weight:bold;
    	text-align:center;
    	color:Green;
    }
    
    table#tblwindows div.more {
    	background: url(Images/document.gif) no-repeat left 2px;
    	position:absolute;
    	bottom:10px;
    	left:10px;
    	text-align:left;
    	padding-left: 12px;
    	padding-bottom: 2px;
    }
    Markup:
    Code:
    <table border="0" cellspacing="10" id="tblwindows">
                        <tr>
                            <td>
                                <div class="container">
                                    <div class="title">
                                        articles
                                    </div>
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    <div class="more">
                                        <a href="#">more</a>
                                    </div>
                                </div>
                            </td>
                            <td>
                                <div class="container">
                                    <div class="title">
                                        articles
                                    </div>
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    <div class="more">
                                        <a href="#">more</a>
                                    </div>
                                </div>
                            </td>
                         </tr>
                        </table>
    In the markup above, the right DIV is longer than the left because it contains more content.

  7. #7
    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

    Yet another reason to avoid tables I suppose.
    - John
    ________________________

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

  8. #8
    Join Date
    Sep 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Yep, I'm convinced that I should avoid tables, but the point is that I don't know how to achieve the same layout with CSS .
    Could you kindly give me a hint on this matter?

    I want my articles to be displayed in equal horizontal couples of frames, it's fairly easy with tables.

    Regards.
    Last edited by niazi; 09-06-2006 at 08:47 AM.

  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

    Just playing with it a bit more, you need to give the td's height so that the 100% height of your container has something to fill. This works well:

    HTML Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    table#tblwindows{
    	width:440px;
    }
    
    table#tblwindows td{
    	background-color:#f0eded;
    	width:50%;
    	height:20em;
    	vertical-align:top;
    	padding:0px;
    	margin:0px;
    	border: solid 1px #d6d9d5;
    }
    
    table#tblwindows div.container{
    	position:relative;
    	height:100%;
    	padding:10px;
    	border: solid 1px blue;
    }
    
    
    table#tblwindows div.title{
    	font-size:12px;
    	font-weight:bold;
    	text-align:center;
    	color:Green;
    }
    
    table#tblwindows div.more {
    	background: url(Images/document.gif) no-repeat left 2px;
    	position:absolute;
    	bottom:10px;
    	left:10px;
    	text-align:left;
    	padding-left: 12px;
    	padding-bottom: 2px;
    }
    </style>
    </head>
    <body>
    <table border="0" cellspacing="10" id="tblwindows">
                        <tr>
                            <td>
                                <div class="container">
                                    <div class="title">
                                        articles
                                    </div>
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    <div class="more">
                                        <a href="#">more</a>
                                    </div>
                                </div>
                            </td>
                            <td>
                                <div class="container">
                                    <div class="title">
                                        articles
                                    </div>
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    blabla blabla<br />
                                    <div class="more">
                                        <a href="#">more</a>
                                    </div>
                                </div>
                            </td>
                         </tr>
                        </table>
    </body>
    </html>
    I used em units for the height of the td's - that way if the browser resizes the text (within reason) it will still all fit.
    - John
    ________________________

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

  10. #10
    Join Date
    Sep 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    jscheuer1, I'm really thankful for your help.

    The problem with setting the height property to a static value is that if the content exceeds the height of the cell, you get a troublesome display. However, do you have an idea on how to achieve the same layout without a table?

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
  •