如何通过DIV将页面划分为多个部分?

时间:2013-08-27 02:51:47

标签: html


我想使用DIV标记将页面分成两个部分,但输出不正确。
这是我的代码:

...

<body>
   <div style="float:right; width: 20ex;background-color:red;">
       my menu content....
   </div>
   <div style="background-color:green;">
         <table style="width:100%; border-style:solid;border-width:5px; border-color:yellow;">
             <tr><td>some content...</td></tr>
         </table>
   </div>
</body>

右div不是从左边div开始,而表格的结尾是左边div。表格的宽度应与rigth div相同,但宽度与页面宽度相同。
右边div是菜单夹,应该是固定宽度(20ex),左边div是我的内容部分,应该填充页面宽度的其余部分。
我无法将固定宽度设置为左div。
有什么问题?

2 个答案:

答案 0 :(得分:0)

我认为你想要的是:

<body>
   <div style="float:right; width: 20ex;background-color:red;inline;width:50%;">
      my menu content....
   </div>
   <div style="float:right; background-color:green;display:inline;width:50%;">
      <table style="width:100%; border-style:solid;border-width:5px; border-color:yellow;">
         <tr><td>some content...</td></tr>
      </table>
   </div>
</body>

try it并告诉我这是否是你想要的

答案 1 :(得分:0)

试试这个:

<body>
   <div style="float:right; width: 100px;background-color:red;">
       my menu content....
   </div>
   <div style="background-color:green;">
         <table style="margin-right:105px; border-style:solid; border-width:5px; border-color:yellow;">
             <tr><td>some content...</td></tr>
         </table>
   </div>
</body>