Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Empty div with 2px width and background color doesnt show with height as 100%

Tags:

html

css

I have a table with 3 columns and first and third column are divided by a vertical line for which i used table with with 100% height and background color which works in fine in FF but doesn't work in Chrome or IE.

Now i replace the table with div tag but empty div doesn't show up. Below is the sample code i tried so many thing now i am confused what to use. Need help from CSS Gurus.

 .PageLine2V
    {
        width:2px;
        content: "";
        min-height: 100%;
        background-color:#D1C094;
        background-image:url('../images/gold-line-2v.gif'); 
        background-repeat:repeat-y;
    }
<table height="100%">
        <td width="60px" valign="top" align="center" >
         <div class="PageLine2V"></div>
        </td>
</table>

I am not sure how i can make this empty div show up and grow with table height also

like image 318
Learning Avatar asked Feb 03 '12 20:02

Learning


2 Answers

 .PageLine2V
    {
        width:2px;
        content: "";
        min-height: 100%;
        background-color:#D1C094;
        background-image:url('../images/gold-line-2v.gif'); 
        background-repeat:repeat-y;
        height: 100%;

    }

Give the div a height of 100%

Also add something in the div such as a space it won't render without content.

<table height="100%">
        <td width="60px" valign="top" align="center" >
         <div class="PageLine2V">&nbsp;</div>
        </td>
</table>
like image 56
Kevin Bowersox Avatar answered Sep 19 '22 19:09

Kevin Bowersox


Setting height to 100% requires that the parent have an explicitly defined height. Add height: 100% to the td (the parent of the div). Tested and working with jsfiddle.

like image 24
kitti Avatar answered Sep 18 '22 19:09

kitti