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

Is it possible to serialize different property sets using DataContractJsonSerializer?

json wcf rest

I'm building a (hopefully) RESTful service using WCF and JSON.

Pyramid project structure

python pyramid

I am developing a rather big project in pyramid. I used django before. I really like the way it structures the project and encapsulate functionality into apps. I would like to achieve same struc...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.