table cell in div is not working

429 Views Asked by At

I am using a table and table cell in my website. The left most column needs to start from the top. Instead it goes to the bottom. Below is a link to that issue where the grey div starts from the very bottom.

http://jsfiddle.net/HtAJw/9/

1

There are 1 best solutions below

0
On

It's not clear what end result you're looking to achieve. However, by adding a pixel width to every element, where it adds up to something less than or equal to the container width, will prevent the wrapping you see.

http://jsfiddle.net/HtAJw/10/

HTML:

<div class="parent">
    <div class="child">
        <fieldset>
                a
        </fieldset>
    </div>
    <div class="child" >
        <div class= "newChildLeft">
                a <br/> b<br/> b<br/> b<br/>
        </div>
        <div class= "newChildRight">
                b<br/> b<br/> b
        </div>
   </div>
</div>

CSS:

.parent {
    width: 100px;
    display: table;
    border: 1px solid green;
    height: 100%
}
.child {
    background: blue;
    display: table-cell;
    height: inherit;
    width: 50px;
}
.newChildLeft {
    float: left;
    width: 25px;
}
.newChildRight {
    float: right
    width: 25px;
}
.child + .child {
    background: red;
    width: 50px;
}
fieldset {
    height: 100%;
    background-color: #666;  
    width: 50px;
}