2016-06-11 54 views
0

如下圖所示,身體上有浮動元素的div,但全部清除。爲什麼身體不是用內部元素擴展的?

守則(https://jsfiddle.net/4ke0cxg7/2/):

html, body { 
 
    height: 100%; 
 
} 
 
body { 
 
    background: grey; 
 
} 
 
#foot { 
 
    position: absolute; 
 
    bottom: 0; 
 
    background: white; 
 
    font-size: 16px; 
 
    font-weight: bold; 
 
} 
 
#h { 
 
    margin-bottom: 20px; 
 
} 
 
#wrapper { 
 
    margin-bottom: 30px; 
 
}
<body> 
 
    <div id="wrapper"> 
 
    <div class="container-fluid"> 
 
     <div class="row-fluid"> 
 
     <div class="span9"> 
 
      <div class="card card-small"> 
 
      <div class="card-heading simple"> 
 
       Phone Book 
 
      </div> 
 
      <div class="card-body"> 
 
       <!-- I have other tabs here --> 
 
       <div class="tab-content"> 
 
       <div class="active tab-pane" id="columns"> 
 
        <table class="table table-striped table-condensed sampleTable"> 
 
        <thead> 
 
         <tr> 
 
         <th>&nbsp;</th> 
 
         <th>Name</th> 
 
         <th>State</th> 
 
         <th>Phone</th> 
 
         </tr> 
 
        </thead> 
 
        <tbody> 
 

 
         <tr> 
 
         <td>0</td> 
 
         <td title="Scroll to the column"> 
 
          <a href="javascript:void(0)" data-row-selector="true" class="column-selector">John</a> 
 
         </td> 
 
         <td>NY</td> 
 
         <td></td> 
 
         </tr> 
 

 
         <!-- Snipped for conciseness --> 
 

 
         <tr> 
 
         <td>21</td> 
 
         <td title="Scroll to the column"> 
 
          <a href="javascript:void(0)" data-row-selector="true" class="column-selector">Rambo</a> 
 
         </td> 
 
         <td>NY</td> 
 
         <td></td> 
 
         </tr> 
 

 
        </tbody> 
 
        </table> 
 
       </div> 
 

 
       </div> 
 
      </div> 
 
      </div> 
 
     </div> 
 
     </div> 
 
    </div> 
 
    </div> 
 
    <div id="foot"> 
 
    Footer 
 
    </div> 
 
</body>

頁腳掛在頁面中間。爲什麼不擴展到包含#wrapper div?

更新:我可以改變任何風格,除了頁腳(它由其他人控制)。爲什麼身體不能展開以包含div?

+0

替換'的位置是:絕對的;'和'位置:relative':https://jsfiddle.net/4ke0cxg7/3/?? –

+0

我看不到問題,但如果您無法控制CSS,則無法修復CSS問題。 – Rob

+0

@Rob - 你在jsFiddle上看不到問題嗎?頁腳粘貼到窗口的底部而不是頁面。嘗試減少預覽窗格的垂直大小... https://jsfiddle.net/4ke0cxg7/4/ – questions

回答

0

改變你的CSS這樣

html { 
    overflow: auto; 
    height: 100vh; 
} 
body { 
    position: relative; 
    background: grey; 
    min-height: 100%; 
} 

Updated fiddle

html { 
 
    overflow: auto; 
 
    height: 100vh; 
 
} 
 
body { 
 
    position: relative; 
 
    background: grey; 
 
    min-height: 100%; 
 
} 
 
#foot { 
 
    position: absolute; 
 
    bottom: 0; 
 
    background: white; 
 
    font-size: 16px; 
 
    font-weight: bold; 
 
} 
 
#h { 
 
    margin-bottom: 20px; 
 
} 
 
#wrapper { 
 
    margin-bottom: 30px; 
 
}
<link href="https://s3-sa-east-1.amazonaws.com/vochani/bootplus.css" rel="stylesheet"/> 
 
    <div id="wrapper"> 
 
    <div class="container-fluid"> 
 
     <div class="row-fluid"> 
 
     <div class="span9"> 
 
      <div class="card card-small"> 
 
      <div class="card-heading simple"> 
 
       Heading 
 
      </div> 
 
      <div class="card-body"> 
 
       <div class="tab-content"> 
 
       <div class="active tab-pane" id="columns"> 
 
        <table class="table table-striped table-condensed sampleTable"> 
 
        <thead> 
 
         <tr> 
 
         <th>&nbsp;</th> 
 
         <th>Name</th> 
 
         <th>State</th> 
 
         <th>Phone</th> 
 
         </tr> 
 
        </thead> 
 
        <tbody> 
 

 
         <tr> 
 
         <td>0</td> 
 
         <td title="Scroll to the column"> 
 
          <a href="javascript:void(0)" data-row-selector="true" class="column-selector">John</a> 
 
         </td> 
 
         <td>NY</td> 
 
         <td></td> 
 
         </tr> 
 

 
         <tr> 
 
         <td>1</td> 
 
         <td title="Scroll to the column"> 
 
          <a href="javascript:void(0)" data-row-selector="true" class="column-selector">Kavita</a> 
 
         </td> 
 
         <td>NY</td> 
 
         <td></td> 
 
         </tr> 
 

 
         <tr> 
 
         <td>2</td> 
 
         <td title="Scroll to the column"> 
 
          <a href="javascript:void(0)" data-row-selector="true" class="column-selector">Luke</a> 
 
         </td> 
 
         <td>NY</td> 
 
         <td></td> 
 
         </tr> 
 

 
         <tr> 
 
         <td>2</td> 
 
         <td title="Scroll to the column"> 
 
          <a href="javascript:void(0)" data-row-selector="true" class="column-selector">Luke</a> 
 
         </td> 
 
         <td>NY</td> 
 
         <td></td> 
 
         </tr> 
 
         <tr> 
 
         <td>2</td> 
 
         <td title="Scroll to the column"> 
 
          <a href="javascript:void(0)" data-row-selector="true" class="column-selector">Luke</a> 
 
         </td> 
 
         <td>NY</td> 
 
         <td></td> 
 
         </tr> 
 
         <tr> 
 
         <td>2</td> 
 
         <td title="Scroll to the column"> 
 
          <a href="javascript:void(0)" data-row-selector="true" class="column-selector">Luke</a> 
 
         </td> 
 
         <td>NY</td> 
 
         <td></td> 
 
         </tr> 
 
         <tr> 
 
         <td>2</td> 
 
         <td title="Scroll to the column"> 
 
          <a href="javascript:void(0)" data-row-selector="true" class="column-selector">Luke</a> 
 
         </td> 
 
         <td>NY</td> 
 
         <td></td> 
 
         </tr> 
 
         <tr> 
 
         <td>2</td> 
 
         <td title="Scroll to the column"> 
 
          <a href="javascript:void(0)" data-row-selector="true" class="column-selector">Luke</a> 
 
         </td> 
 
         <td>NY</td> 
 
         <td></td> 
 
         </tr> 
 
         <tr> 
 
         <td>2</td> 
 
         <td title="Scroll to the column"> 
 
          <a href="javascript:void(0)" data-row-selector="true" class="column-selector">Luke</a> 
 
         </td> 
 
         <td>NY</td> 
 
         <td></td> 
 
         </tr> 
 
         <tr> 
 
         <td>3</td> 
 
         <td title="Scroll to the column"> 
 
          <a href="javascript:void(0)" data-row-selector="true" class="column-selector">Bob</a> 
 
         </td> 
 
         <td>NY</td> 
 
         <td></td> 
 
         </tr> 
 

 
         <tr> 
 
         <td>4</td> 
 
         <td title="Scroll to the column"> 
 
          <a href="javascript:void(0)" data-row-selector="true" class="column-selector">Peter</a> 
 
         </td> 
 
         <td>WA</td> 
 
         <td></td> 
 
         </tr> 
 

 
         <tr> 
 
         <td>5</td> 
 
         <td title="Scroll to the column"> 
 
          <a href="javascript:void(0)" data-row-selector="true" class="column-selector">Mike</a> 
 
         </td> 
 
         <td>CA</td> 
 
         <td></td> 
 
         </tr> 
 

 
         <tr> 
 
         <td>6</td> 
 
         <td title="Scroll to the column"> 
 
          <a href="javascript:void(0)" data-row-selector="true" class="column-selector">Andrew</a> 
 
         </td> 
 
         <td>CA</td> 
 
         <td></td> 
 
         </tr> 
 

 
         <tr> 
 
         <td>7</td> 
 
         <td title="Scroll to the column"> 
 
          <a href="javascript:void(0)" data-row-selector="true" class="column-selector">Hilo</a> 
 
         </td> 
 
         <td>CA</td> 
 
         <td></td> 
 
         </tr> 
 

 
         <tr> 
 
         <td>8</td> 
 
         <td title="Scroll to the column"> 
 
          <a href="javascript:void(0)" data-row-selector="true" class="column-selector">Jeff</a> 
 
         </td> 
 
         <td>CA</td> 
 
         <td></td> 
 
         </tr> 
 

 
         <tr> 
 
         <td>9</td> 
 
         <td title="Scroll to the column"> 
 
          <a href="javascript:void(0)" data-row-selector="true" class="column-selector">Elon</a> 
 
         </td> 
 
         <td>WA</td> 
 
         <td></td> 
 
         </tr> 
 

 
         <tr> 
 
         <td>10</td> 
 
         <td title="Scroll to the column"> 
 
          <a href="javascript:void(0)" data-row-selector="true" class="column-selector">Cindy</a> 
 
         </td> 
 
         <td>CA</td> 
 
         <td></td> 
 
         </tr> 
 

 
         <tr> 
 
         <td>11</td> 
 
         <td title="Scroll to the column"> 
 
          <a href="javascript:void(0)" data-row-selector="true" class="column-selector">Bri</a> 
 
         </td> 
 
         <td>CA</td> 
 
         <td></td> 
 
         </tr> 
 

 
         <tr> 
 
         <td>12</td> 
 
         <td title="Scroll to the column"> 
 
          <a href="javascript:void(0)" data-row-selector="true" class="column-selector">Brian</a> 
 
         </td> 
 
         <td>CA</td> 
 
         <td></td> 
 
         </tr> 
 

 
         <tr> 
 
         <td>13</td> 
 
         <td title="Scroll to the column"> 
 
          <a href="javascript:void(0)" data-row-selector="true" class="column-selector">NIck</a> 
 
         </td> 
 
         <td>CA</td> 
 
         <td></td> 
 
         </tr> 
 

 
         <tr> 
 
         <td>14</td> 
 
         <td title="Scroll to the column"> 
 
          <a href="javascript:void(0)" data-row-selector="true" class="column-selector">Miranda</a> 
 
         </td> 
 
         <td>CA</td> 
 
         <td></td> 
 
         </tr> 
 

 
         <tr> 
 
         <td>15</td> 
 
         <td title="Scroll to the column"> 
 
          <a href="javascript:void(0)" data-row-selector="true" class="column-selector">Lauren</a> 
 
         </td> 
 
         <td>CA</td> 
 
         <td></td> 
 
         </tr> 
 

 
         <tr> 
 
         <td>16</td> 
 
         <td title="Scroll to the column"> 
 
          <a href="javascript:void(0)" data-row-selector="true" class="column-selector">Cherry</a> 
 
         </td> 
 
         <td>CA</td> 
 
         <td></td> 
 
         </tr> 
 

 
         <tr> 
 
         <td>17</td> 
 
         <td title="Scroll to the column"> 
 
          <a href="javascript:void(0)" data-row-selector="true" class="column-selector">Jessica</a> 
 
         </td> 
 
         <td>CA</td> 
 
         <td></td> 
 
         </tr> 
 

 
         <tr> 
 
         <td>18</td> 
 
         <td title="Scroll to the column"> 
 
          <a href="javascript:void(0)" data-row-selector="true" class="column-selector">Bom</a> 
 
         </td> 
 
         <td>CA</td> 
 
         <td></td> 
 
         </tr> 
 

 
         <tr> 
 
         <td>19</td> 
 
         <td title="Scroll to the column"> 
 
          <a href="javascript:void(0)" data-row-selector="true" class="column-selector">Ram</a> 
 
         </td> 
 
         <td>NY</td> 
 
         <td></td> 
 
         </tr> 
 

 
         <tr> 
 
         <td>20</td> 
 
         <td title="Scroll to the column"> 
 
          <a href="javascript:void(0)" data-row-selector="true" class="column-selector">Telco</a> 
 
         </td> 
 
         <td>WA</td> 
 
         <td></td> 
 
         </tr> 
 

 
         <tr> 
 
         <td>21</td> 
 
         <td title="Scroll to the column"> 
 
          <a href="javascript:void(0)" data-row-selector="true" class="column-selector">Rambo</a> 
 
         </td> 
 
         <td>NY</td> 
 
         <td></td> 
 
         </tr> 
 

 
        </tbody> 
 
        </table> 
 
       </div> 
 

 
       </div> 
 
      </div> 
 
      </div> 
 
     </div> 
 
     </div> 
 
    </div> 
 
    </div> 
 
    <div id="foot"> 
 
    Footer 
 
    </div>

相關問題