太棒了,我似乎无法让一些 div 对齐工作。基本上,我有一个容器 div,我想要 div 内的左列和右列,基本上右列总是垂直大于左列。所以我希望左列在右列旁边垂直居中。这是我的CSS:
.recipe_container{
float:center;
width:800px;
position:relative;
padding:0px;
border:5px solid #B22222;
margin:0px auto;
}
.recipe_container_left{
float:left;
width:390px;
position:relative;
top:50%;
padding:4px;
border-right:1px solid;
margin:0px auto;
}
.recipe_container_right{
float:right;
width:390px;
position:relative;
padding:4px;
border-right:1px solid;
margin:0px auto;
}
并且 html 像这样依偎
<div class="recipe_container">
<div class="recipe_container_left">
recipe title and ingredients
</div>
<div class="recipe_container_right">
recipe cooking instructions
</div>
</div>
但左侧“recipe_container_left”div 不在父“recipe_container”div 内垂直居中。我已经在谷歌上搜索了一段时间,似乎无法得到任何工作。我知道,新手问题。有什么帮助吗?
就像这就是我想要的结果(动态缩放到浏览器窗口):
------------------------------------------------------------
recipe_container ============================
| |
| recipe_container_right |
=========================== | recipe cooking- |
| recipe_container_left | | -instructions |
| recipe title+ingredients| | |
| | | |
=========================== | |
| |
| |
============================
------------------------------------------------------------
(repeat)