Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html Div宽度与子内容不匹配_Html_Css_Twitter Bootstrap - Fatal编程技术网

Html Div宽度与子内容不匹配

Html Div宽度与子内容不匹配,html,css,twitter-bootstrap,Html,Css,Twitter Bootstrap,如何使用引导使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>

如何使用引导使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>
  </div>
</div>


我假设您使用的类是twitter引导,如果是,那么您的标记是错误的

<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>

此外,span*是浮动的,因此除非它们位于“row”元素内,否则您需要使用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>


您是否尝试过将div width设置为与.span12相同的宽度?这样,宽度将变为与父级相同,而不是内容编辑不适合您请求帮助。请耐心等待。谢谢,我们将按照规则进行更改。