4

我试图获得以下布局超过 1.5 小时,但仍然无法获得正确的解决方案。

好吧,如果有任何重复,请原谅我问这个问题。

我想使用 div 标签进行如下图的布局:

| _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ _ __ _ __ _ __ _ _ __ _ __ | | | | | | | | | | | | | | _ __ _ __ _ __ _ __ ___ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ _ _ __ _ ___ | | | | | | | | | | | | | | | | | | | | | | | | | | | | |__ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ _ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ _ _ _ __ _ __ _ _ _ _ __ _ _

我知道如何使用表格标签来做到这一点。

4

3 回答 3

7

float:left是你的朋友

HTML:

<div id="wrapper">
    <div id="first"></div>
    <div id="second"></div>
    <div id="third"></div>
</div>

CSS:

div {
    display: block;
}
#wrapper {
    width: 400px;
    height:400px;
}

#first {
    float:left;
    width: 33%;
    height: 100%;
    background: red;
}

#second {
    float:left;
    width: 67%;
    height: 30%;
    background: green;
}

#third {
    float:left;
    width: 67%;
    height: 70%;
    background: blue;
}

示例:http: //jsfiddle.net/Vkmq3/1/

于 2013-07-26T14:25:38.293 回答
5

这是确切的JSFiddleJSBin

CSS设为

#upleft { 
   width:100px; 
   height: 300px; 
   background:red; float:left; 
}

#upright { 
   width:300px; 
   height:200px; 
   background:blue; 
   float:left
}
#below { 
   height:300px; 
   width:400px; 
   background:green 
}

HTML中

<div id="upleft"></div>
<div id="upright"></div>
<div id="below"></div>
于 2013-07-26T14:26:36.607 回答
0

试试这个 css 和 html 代码:

CSS:

<style type="text/css">
#left {
  float:left;
  width:27%;
  height: 25em;
  margin:1px .2em 1px 1px;
  border: 2px solid green;
}
#content {
  margin:1px .2em 1px 28%;
}
#cnt1 {
  position;relative;
  margin:.3em 2px;
  height: 10em;
  border: 1px solid blue;
}
#cnt2 {
  position;relative;
  margin:.3em 2px;
  height: 100%;
}
</style>

HTML:

<div id="left">Left side</div>
<div id="content">
  <div id="cnt1">Up</div>
  <div id="cnt2">Down</div>
</div>
<br style="clear:both;" />
于 2013-07-26T14:33:38.907 回答