如果问题没有完全意义,这可能。
|----------------------------------------------|
| |
| |
| IIIIIIIII IIIIIIIII IIIIIIIII IIIIIIIII | Main div holding for divs.
| |
| |
|----------------------------------------------|
屏幕大小调整:
|------------------------------------|
| |
| IIIIIIIII IIIIIIIII IIIIIIIII |
| | Divs get divided into 2 rows,
| IIIIIIIII | but still vertically aligned.
| |
|------------------------------------|
怎么样? 提前致谢!
这是 jsfiddle 链接
水平调整“结果”的大小。 假设单行的高度为 10px,容器的高度为 50px。当所有链接都可以放在一行中时,链接应在其上方 20px 和下方 20px。当窗口调整大小时,盒子变成两行而不是一行,两行仍应位于容器 div 的中心。例如,顶部有 15px,底部有 15px。 (如果两行之间没有边距。
更好的解释?
最佳答案
如果您调整菜单的顶部位置会怎样?像这样:
#menu {
float:right;
margin:0 20px 0 0;
width:50%;
position:relative;
top:10%;
}
关于javascript - 即使在调整大小时形成多行, float div 也应保持垂直居中。如何?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8811364/