我不知道如何构建这个简单的布局。
这就是我想要的样子:
......这就是我到目前为止:
如何在右上角找到黄色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;
}
答案 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>
演示
答案 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!