CSS div定位问题

时间:2013-07-05 14:11:29

标签: html css css-float positioning

我不知道如何构建这个简单的布局。

这就是我想要的样子:

enter image description here

......这就是我到目前为止:

http://cssdesk.com/vQ3qr

如何在右上角找到黄色div?

HTML:

<div class="gray-wrapper">
   <div class="red">centered</div>
   <div class="yellow">top right corner</div>
   <div class="aqua">100% width</div>
</div>

CSS

.gray-wrapper{
width:500px;
height:200px;
background:gray;
border:4px solid gray;
}
.red{
width:200px;
height:100px;
margin:0 auto;
background:red;

}
.yellow{
width:50px;
height:100px;
float:right;
background:yellow;
}
.aqua{
width:100%;
height:100px;
background:aqua;
}

2 个答案:

答案 0 :(得分:4)

只需将yellow div放在html ..

<div class="gray-wrapper">
   <div class="yellow">top right corner</div>
   <div class="red">centered</div>
   <div class="aqua">100% width</div>
</div>

http://cssdesk.com/KYRTT

演示

答案 1 :(得分:1)

body{background:white}


.gray-wrapper{
 width:500px;
height:200px;
background:gray;
border:4px solid gray;
}


.red{
width:200px;
height:100px;
margin-left: 150px;
background:red;
 float:left; 



}


.yellow{
width:50px;
height:100px;
float:right;
background:yellow;
}


.aqua{
width:100%;
height:100px;
background:aqua;
float: left;
}

DONE!