【发布时间】:2017-05-19 06:16:52
【问题描述】:
我正在尝试为我的网页上的某个单词添加下划线动画。它可以工作,但下划线在 div 下显示文本在里面。您可以在 sn-p 上看到 div 应该填满整个显示屏,但现在您必须向下滚动才能看到下划线。如何让它显示在文本下方?
body {
margin: 0;
padding: 0;
}
div {
width: 50%;
height: 100vh;
text-align: center;
line-height: 100vh;
font-size: 150%;
top: 0;
-webkit-transition: font-size 0.5s;
-moz-transition: font-size 0.5s;
-o-transition: font-size 0.5s;
transition: font-size 0.5s;
}
div:hover {
font-size: 200%;
}
a {
display: inline-block;
position: relative;
padding-bottom: 3px;
}
a:after {
content: '';
display: block;
margin: auto;
height: 3px;
width: 0px;
background: transparent;
transition: width .5s ease, background-color .5s ease;
}
a:hover:after {
width: 100%;
background: blue;
}
<div style="background-color: rgb(64, 64, 64); color: rgb(255, 255, 255); float: left;">
<a>Webpage</a>
</div>
<div style="background-color: rgb(255, 255, 255); color: rgb(64, 64, 64); float: right;">
<a>Photos</a>
</div>
【问题讨论】: