1

Fiddle
I have two Div , one is in table and other , outside of table .
My problem is , as you can see , divOne overflow outside of parent Div .
I want to show like

 ---------------------
|  ----    ----       |
| |    |  | D2 |      |
| | D1 |  |    |      |
| |    |   ----       |
| |    |              | 
|  ----               |
 ---------------------

Here is my code ,

html

   <div class="wrapper">
    <textarea rows="12" cols="8" class="divOne">
        Division One
    </textarea>    
    <table>
        <tr>
            <td>
    <textarea rows="6" cols="8" class="divOne">    
     Division Two
     </textarea>    
            </td>
        </tr>        
    </table>    
      </div>

Css

.wrapper
{   
    border: 1px solid #999999;
    position: relative;
    margin: 0px;
    padding: 10px;
    width: 600px;
    background-color: #FCFCFC;
    min-height: 50px;
    color: black;
    border-radius: 8px;
    -moz-border-radius: 8px;   
    line-height:normal;     
}

.divOne
{
   float:left;    
}
Mr. Alien
  • 153,751
  • 34
  • 298
  • 278
zey
  • 5,939
  • 14
  • 56
  • 110

5 Answers5

3

http://jsfiddle.net/fNhet/1/

.wrapper {
    display: inline-block;
}
CRABOLO
  • 8,605
  • 39
  • 41
  • 68
  • 2
    No offence with the answer but this is not the solution to the question :) you are changing the display property of the parent element which is a block level, so you shouldn't alter, the issue is of **uncleared floats** – Mr. Alien Jan 29 '14 at 10:21
2

The issue over there is that you are using floats but you aren't clearing

.wrapper:after { /* Using a clearfix */
    display: table;
    content: "";
    clear: both;
}

Demo

So, the parent takes the height of the non floated elements... and thus the background doesn't increase.

For more information on float and clear, read my answers here and here.

Community
  • 1
  • 1
Mr. Alien
  • 153,751
  • 34
  • 298
  • 278
1

In your css try addding to your .wrapper
CSS:-

overflow:hidden;

DEMO.This will do the trick.

malcolmX
  • 429
  • 4
  • 15
1

use display: inline-block; overflow: hidden; width: 50% .. this will give you some additional effect

Moorthy GK
  • 1,283
  • 9
  • 17
1

Add display:inline-block; to wrapper div then you can get the result.....