transition
プロパティを利用し、 span
要素のホバー時に span
要素の ::after
擬似要素に適用されている box-shadow
, background-color
, z-index
プロパティを変更すれば良いです。これに加えて、::after
擬似要素へ top
プロパティを追加し、以下のようにすることで質問者さんの実現したいことが行えると思います (動作確認用リンク)。
HTML
1<div class="col-md-4">
2 <h2>Redacted</h2>
3 <p class="redacted">The home of <span>these birds</span> was on the shore of <span>the lake Stymphalis</span>, in <span>Arcadia</span> (after which they were called), where they <span>caused great destruction</span> among men and cattle.</p>
4</div>
SCSS
1$white: #fafafa;
2
3body {
4 background: $white;
5 color: rgba(0, 0, 0, 0.84);
6 font-size: 20px;
7 line-height: 1.5;
8 padding-top: 1em;
9}
10
11.redacted span {
12 position: relative;
13 white-space: pre;
14
15 &:hover {
16 &::after {
17 box-shadow: none; /* 追加 */
18 background: transparent; /* 追加 */
19 z-index: -1; /* 追加 */
20 }
21 }
22
23 &:after {
24 background: black;
25 border-radius: 0.1em;
26 box-shadow: 0 0 1px rgba(0, 0, 0, 0.35);
27 content: " ";
28 width: 100%;
29 height: 1.2em;
30 top: 0; /* 追加 */
31 left: 0;
32 position: absolute;
33 transform: skewY(-5deg) rotate(5deg);
34 transition: 1s all; /* 追加 */
35 }
36}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/12/08 21:08