DIV在左右两侧定位

时间:2014-08-31 17:54:57

标签: css positioning

我是html和css的新手我想要构建一个页面,右侧左侧有3layout,中间部分将是内容 我的问题是如何在右侧和左侧放置div 我在Dreamweaver中尝试过APdiv,但它重叠了 请给我一个解决方案

2 个答案:

答案 0 :(得分:1)

使用

float:left;

表示左,

float:right;

为了对。并且之前搜索,请你在网上轻松找到这个问题的答案。

答案 1 :(得分:0)

这是进行3列网页的一种方式:

HTML:

...

<body>
 <div id="container">
  <div id="left">LEFT</div>
  <div id="center">CENTER</div>
  <div id="right">RIGHT</div>
 </div>
</body>

...

CSS:

#container{
 width: 960px;
 margin: 0 auto;
 overflow: hidden; /* This is not to overlap */
}

#left{
 width: 200px;
 height: 800px;
 background-color: red;
 float: left;
}

#center{
 width: 560px;
 height: 800px;
 background-color: blue;
 float: left;
}

#right{
 width: 200px;
 height: 800px;
 background-color: green;
 float: left; /* you can do here float:right also */
}
相关问题