私のウェブページ上の単語の下線をアニメーション表示しようとしています。それは動作しますが、下線はdivの下にテキストが内部にあることを示しています。スニペットでdivが表示全体を満たすはずですが、スクロールして下線を表示する必要があります。テキストの下に表示するにはどうしたらいいですか?代わりにブラケットを使用してのCSSのテキストが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>
その理由を知りたいですか? – xxCodexx
@xxCodexx divの線高は100vhです。 aはdiv内にあるので、この設定は**カスケード**になります。また、大きな値であるため、偽の下線を非常に低く設定します。 * initial *に再度設定すると元の値に戻ります。 – vals