到处搜索,外面的每一种情况都不适合我。如何在每个列表项中垂直居中文本?我确实需要保留覆盖背景图像的链接(可点击区域)。
HTML
<section>
<ul>
<li><a id="monday" href="_monday.html"><span>Monday</span></a></li>
<li><a id="tuesday" href="_tuesday.html"><span>Tuesday</span></a></li>
<li><a id="wednesday" href="_wednesday.html"><span>Wednesday</span></a></li>
<li><a id="thursday" href="_thursday.html"><span>Thursday</span></a></li>
<li><a id="friday" href="_friday.html"><span>Friday</span></a></li>
<li><a id="saturday" href="_saturday.html"><span>Saturday</span></a></li>
<li><a id="sunday" href="_sunday.html"><span>Sunday</span></a></li>
<li><a id="printAll" href="_week.html"><span>Print All Specials</span></a></li>
</ul>
CSS(它的一些版本——我还在学习很多东西:)
section {
max-width:86.029411764%;
margin: -6px auto auto auto;
overflow: hidden;
}
section ul {
display: inline-block;
width: 35%;
height: 100%;
min-width: 320px;
margin-left: 1rem;
margin-right: 1rem;
}
section li {
position: relative;
display: block;
background: url(_images/daybg_06.png) center center no-repeat;
background-size: contain;
padding-top: 14.95%;
margin: 20px auto 20px auto;
}
section ul li a {
position: absolute;
display: block;
bottom: 0;
left: 0;
right: 0;
top: 0;
font-size: 1.3rem;
color: white;
text-decoration: none;
text-align: center;
}
section ul li a span {
}