我想垂直居中对齐按钮,即使height
和line-height
的{{1}}发生更改,或按钮的li
发生更改,它也应保持垂直对齐
font-size

ul {
display: table;
width: 300px;
list-style: none;
list-style-image: none;
margin: 0;
padding: 0;
background-color: aqua;
}
ul li {
float: right;
margin-right: 8px;
height: 80px;
line-height: 80px;
}
ul li.header-logo {
float: left;
font-size: 50px;
}
#button {
padding: 4px 6px;
background-color: #ff9191;
border: 2px solid #00b5cc;
line-height: 24px;
}

答案 0 :(得分:2)
添加一个显示:内联到您的按钮 - 它应该没问题
ul {
display: table;
width: 300px;
list-style: none;
list-style-image: none;
margin: 0;
padding: 0;
background-color: aqua;
}
ul li {
float: right;
margin-right: 8px;
height: 80px;
line-height: 80px;
}
ul li.header-logo {
float: left;
font-size: 50px;
}
#button {
display:inline;
padding: 4px 6px;
background-color: #ff9191;
border: 2px solid #00b5cc;
line-height: 24px;
}
<div id="logo-row">
<ul>
<li class="header-logo">AAA</li>
<li><div id="button">BUTTON</div></li>
<li>LINK</li>
</ul>
</div>