Div width not fit with child contents

How to fit the div with its contents using bootstrap.

<div class="row-fluid">
  <div class="span12">
    <div style="<!--tried with inline-block float:left clear:left white-space:nowrap width:auto -->">
      <div class="span6">
        <table>
        </table>
      </div>
    </div>
  </div>
</div>

nothing working with any of the styles. Please help me..

Answers


I assume by the classes you are using this is twitter bootstrap, if so, your markup is wrong.

<div class="row-fluid">
  <div class="span12">
    <!-- span6 inside span12 will not use up 50% space unless it is the first child of a row --> 
    <div class="row-fluid"> 
      <div class="span6">
        <table>
        </table>
      </div>
    </div>
  </div>
</div>

Also, span* are floated, so unless they are inside a "row" element you need to use a clearfix div

<div class="row-fluid">
  <div class="span12">
    <div style="<!--tried with inline-block float:left clear:left white-space:nowrap width:auto -->">
      <div class="span6">
        <table>
        </table>
      </div>
      <div class="clearfix"></div>
    </div>
  </div>
</div>

And last, you can always try using a "overflow:hidden" on a container div to make it adapt to its floated children.


Need Your Help

How to convert an InputStream() to a Scanner() Java

java file text inputstream

I am working on an android app so I need to use an InputStream() to read a txt file but I also have several methods that only work with Scanner() so I need a way to convert InputStream() to Scanner...

JBOSS: EJB how to fix java.lang.reflect.UndeclaredThrowableException?

java jboss ejb ejb-3.0 ejb-3.1

inside a bean i try to list all the articles with this method