English 中文(简体)
为什么这个DIV不扩展到孩子们的宽度
原标题:Why doesn t this DIV expand to the width of the children
  • 时间:2011-02-09 20:58:32
  •  标签:
  • html
  • css

我有一个问题,想知道为什么我的包含DIV没有扩展到大表的宽度?

<html>
   <head>
      <link rel="stylesheet" href="http://www.blueprintcss.org/blueprint/screen.css" type="text/css" media="screen, projection" />
      <link rel="stylesheet" href="http://www.blueprintcss.org/blueprint/print.css" type="text/css" media="print" />
      <!--[if lt IE 8]><link rel="stylesheet" href="http://www.blueprintcss.org/blueprint/ie.css" type="text/css" media="screen, projection" /><![endif]-->
      <style type="text/css">
         div.add-padding {
            padding: 15px;
            background-color: red;
         }
         table {
            background-color: blue;
         }
      </style>
   </head>
   <body>
      <div class="add-padding">
         <table>
            <thead>
               <tr><td>FOO</td></tr>
            </thead>
            <tbody>
               <tr><td>BAR</td></tr>
            </tbody>
         </table>
         <table>
            <thead>
               <tr>
                  <td>SEQ</td>
                  <td>ID</td>
                  <td>ParentID</td>
                  <td>Case Category</td>
                  <td>Case #</td>
                  <td>Case ID</td>
                  <td>Account Code</td>
                  <td>Account Code ID</td>
                  <td>Trans Date</td>
                  <td>Person ID</td>
                  <td>FullName</td>
                  <td>Suffix</td>
                  <td>PayeeID</td>
                  <td>OperatorID</td>
                  <td>Notes</td>
                  <td>CheckID</td>
                  <td>ReceiptID</td>
                  <td>Void</td>
                  <td>TransCategoryID</td>
                  <td>CaseFull</td>
                  <td>TransTypeID</td>
                  <td>Xfer To</td>
                  <td>Ref #</td>
                  <td>View Amount</td>
               </tr>
            </thead>
            <tbody>
               <tr>
                  <td>foo_bar</td>
                  <td>foo_bar</td>
                  <td>foo_bar</td>
                  <td>foo_bar</td>
                  <td>foo_bar</td>
                  <td>foo_bar</td>
                  <td>foo_bar</td>
                  <td>foo_bar</td>
                  <td>foo_bar</td>
                  <td>foo_bar</td>
                  <td>foo_bar</td>
                  <td>foo_bar</td>
                  <td>foo_bar</td>
                  <td>foo_bar</td>
                  <td>foo_bar</td>
                  <td>foo_bar</td>
                  <td>foo_bar</td>
                  <td>foo_bar</td>
                  <td>foo_bar</td>
                  <td>foo_bar</td>
                  <td>foo_bar</td>
                  <td>foo_bar</td>
                  <td>foo_bar</td>
                  <td>foo_bar</td>
               </tr>
            </tbody>
         </table>
      </div>
   </body>
</html>
最佳回答

不是100%确定这是你想要的,但试试这个:

  • You should add <!DOCTYPE html> (the HTML5 doctype) as your very first line (you must do this to escape quirks mode and help to ensure consistent rendering between different browsers).
  • Add float: left to div.add-padding.

现场演示

问题回答

这对萤火虫来说是个完美的问题。右键单击inspect元素,然后查找布局选项卡。您可以将css/样式跟踪到父级。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签