如何垂直对齐页脚中的文本并从 ::after 内容中删除下划线
How can I vertically align text in my footer and also remove underline from ::after content
所以我有两个问题:
1。如何使页脚中的文本垂直对齐两行或多行?
(我只是将行高与页脚的高度对齐以对齐一行,但它在两行或多行之间留下了巨大的间隙)
2。如何从 CSS ::after content 中删除下划线,但将其保留在文本下方。
(因此所有链接在悬停时都会像最后一个一样)
HTML & CSS
footer {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
min-height: 50px;
line-height: 50px;
text-align: center;
margin-top: auto;
margin-bottom: auto;
color: white;
background-color: #232323;
}
footer a {
cursor: pointer;
}
footer a:hover {
text-decoration: underline;
}
footer a:not(:last-child)::after {
content: " | ";
cursor: default;
}
<footer>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
</footer>
JSFIDDLE
https://jsfiddle.net/qmbbtmb5/
您可以通过将 position: absolute
css 属性 添加到 :after
伪选择器来使其按您希望的方式工作。尝试像这样调整您的 css 代码。
footer {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
min-height: 50px;
text-align: center;
line-height: 1.5;
margin-top: auto;
margin-bottom: auto;
color: white;
background-color: #232323;
padding: 30px 0;
}
footer a {
cursor: pointer;
display: inline-block;
position: relative;
margin: 0 5px;
}
footer a:hover {
text-decoration: underline;
}
footer a:not(:last-child)::after {
content: " | ";
cursor: default;
position: absolute;
top: 0;
right: -10px;
}
所以我有两个问题:
1。如何使页脚中的文本垂直对齐两行或多行?
(我只是将行高与页脚的高度对齐以对齐一行,但它在两行或多行之间留下了巨大的间隙)
2。如何从 CSS ::after content 中删除下划线,但将其保留在文本下方。
(因此所有链接在悬停时都会像最后一个一样)
HTML & CSS
footer {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
min-height: 50px;
line-height: 50px;
text-align: center;
margin-top: auto;
margin-bottom: auto;
color: white;
background-color: #232323;
}
footer a {
cursor: pointer;
}
footer a:hover {
text-decoration: underline;
}
footer a:not(:last-child)::after {
content: " | ";
cursor: default;
}
<footer>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
<a>Link</a>
</footer>
JSFIDDLE
https://jsfiddle.net/qmbbtmb5/
您可以通过将 position: absolute
css 属性 添加到 :after
伪选择器来使其按您希望的方式工作。尝试像这样调整您的 css 代码。
footer {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
min-height: 50px;
text-align: center;
line-height: 1.5;
margin-top: auto;
margin-bottom: auto;
color: white;
background-color: #232323;
padding: 30px 0;
}
footer a {
cursor: pointer;
display: inline-block;
position: relative;
margin: 0 5px;
}
footer a:hover {
text-decoration: underline;
}
footer a:not(:last-child)::after {
content: " | ";
cursor: default;
position: absolute;
top: 0;
right: -10px;
}