【发布时间】:2016-07-01 11:47:32
【问题描述】:
我正在尝试制作一个导航栏,其中按钮的文本将垂直居中对齐。
目前,除了垂直对齐之外,导航栏一切正常。
我尝试了很多方法,例如行高、顶部和底部填充(弄乱了我的高度,导致文本 div 溢出)、flex 和表格显示。
html,
body {
height: 100%;
margin: 0px;
}
#nav {
height: 10%;
background-color: rgb(52, 152, 219);
position: fixed;
top: 0;
left: 0;
width: 100%;
color: white;
font-family: Calibri;
font-size: 200%;
text-align: center;
display: flex;
}
#nav div {
display: inline-block;
height: 100%;
align-items: stretch;
flex: 1;
}
#nav div:hover {
background-color: rgb(41, 128, 185);
cursor: pointer;
}
<div id="main">
<div id="nav">
<div><a>Home</a></div>
<div><a>Page2</a></div>
<div><a>Page3</a></div>
<div><a>Page4</a></div>
<div><a>Page5</a></div>
</div>
</div>
感谢所有帮助,谢谢!
【问题讨论】:
标签: html css flexbox css-tables