HTML将一个部分拆分为两列

时间:2013-02-22 17:35:41

标签: html

我试图将页面分成两部分。左侧区域和右侧区域将是内容页面。我有以下的HTML,但看起来它不起作用。任何想法,我做得不对?

<div id="wuiMainArea">
    <div id="wuiMainContent">

      <div id="wuiLeftArea">
        <div id="wuiLefthandNavRoot">
            <h2 class="wui-hidden">Section Navigation</h2>
            <h3 class="wui-navigation-title"><p>Applications</p><p>&nbsp;</p></h3>
            <div id="tree" style="float: left; width: auto; background-color: #f2f4f5;"> </div>
        </div>
        </div>

      <div id="wuiInpageNav">
            <div class="wui-inpage-container" id="in_100">
              <p>This is the div I will be using for charts </p>
            </div>
      </div>

      </div>
 </div>

2 个答案:

答案 0 :(得分:0)

喜欢这个

<div id="wuiMainArea" style="border: 1px solid;">
    <div id="wuiMainContent" style="border: 1px solid;">

        <div id="wuiLeftArea" style="border: 1px solid;float: left;">
            <div id="wuiLefthandNavRoot">
                <h2 class="wui-hidden">Section Navigation</h2>
                <h3 class="wui-navigation-title"><p>Applications</p><p>&nbsp;</p></h3>
                <div id="tree" style="float: left; width: auto; background-color: #f2f4f5;"> </div>
            </div>
        </div>

        <div id="wuiInpageNav" style="border: 1px solid; float: left;">
            <div class="wui-inpage-container" id="in_100">
                <p>This is the div I will be using for charts </p>
            </div>
        </div>
        <div style="clear: both;"></div>
    </div>
</div>

答案 1 :(得分:0)

 #wuiMainArea, #wuiMainContent{
    margin: 0 auto;
    width: 960px;
}

 #wuiLeftArea, #wuiInpageNav{
/* use half of the main content div's width */
/* -2 because of 1px-border on both sides */
    width: 478px; 
    display: inline-block;
    float: left;
}

使用CSS样式HTML会更好。 定义宽度以满足您的需求。此外,我建议在将相同样式应用于多个元素时使用类而不是ID。