簡體   English   中英

CSS Hover 下划線 Animation

[英]CSS Hover Underline Animation

當我在一段文本上使用 hover 時,我正在嘗試創建一行 animation。 這是我現在擁有的代碼,但它不起作用。

[data-predefined-style="true"] small {
    display: inline-block;
    font-size: 1.8rem;
    line-height: 1.2;
    font-family: "Diatype Variable", Icons;
    font-style: normal;
    font-weight: 500;
    color: rgba(0, 0, 0, 0.85);
    font-variation-settings: 'slnt' 0, 'MONO' 0;
}

[data-predefined-style="true"] small a {
    color: rgba(0, 0, 0, 0.85);
    border-bottom-width: 0em;
}

[data-predefined-style="true"] small a:hover {
    color: rgba(0, 46, 207, 0.8);
    border-bottom-width: 0em;
}

.hover-underline-animation {
  display: inline-block;
  position: relative;
  color: #0087ca;
}

.hover-underline-animation:after {
  content: '';
  position: absolute;
  width: 100%;
  transform: scaleX(0);
  height: 2px;
  bottom: 0;
  left: 0;
  background-color: #0087ca;
  transform-origin: bottom right;
  transition: transform 0.25s ease-out;
}

.hover-underline-animation:hover:after {
  transform: scaleX(1);
  transform-origin: bottom left;
}

我有 hover animation 的代碼,但我不確定如何實現它。 非常感謝您的幫助,非常感謝!

似乎正在工作。 你追求什么樣的效果?

 [data-predefined-style="true"] small { display: inline-block; font-size: 1.8rem; line-height: 1.2; font-family: "Diatype Variable", Icons; font-style: normal; font-weight: 500; color: rgba(0, 0, 0, 0.85); } [data-predefined-style="true"] small a { color: rgba(0, 0, 0, 0.85); border-bottom-width: 0em; } [data-predefined-style="true"] small a:hover { color: rgba(0, 46, 207, 0.8); border-bottom-width: 0em; }.hover-underline-animation { display: inline-block; position: relative; color: #0087ca; }.hover-underline-animation:after { content: ''; position: absolute; width: 100%; transform: scaleX(0); height: 2px; bottom: 0; left: 0; background-color: #0087ca; transform-origin: bottom right; transition: transform 0.25s ease-out; }.hover-underline-animation:hover:after { transform: scaleX(1); transform-origin: bottom left; }
 <div class="hover-underline-animation">Hello world</div>

希望這可以幫到你

 [data-predefined-style="true"] small { display: inline-block; font-size: 1.8rem; line-height: 1.2; font-family: "Diatype Variable", Icons; font-style: normal; font-weight: 500; color: rgba(0, 0, 0, 0.85); font-variation-settings: 'slnt' 0, 'MONO' 0; } [data-predefined-style="true"] small a { color: rgba(0, 0, 0, 0.85); border-bottom-width: 0em; } [data-predefined-style="true"] small a:hover { color: rgba(0, 46, 207, 0.8); border-bottom-width: 0em; }.hover-underline-animation { display: inline-block; position: relative; color: #0087ca; }.hover-underline-animation:after { content: ''; position: absolute; width: 100%; transform: scaleX(0); height: 2px; bottom: 0; left: 0; background-color: #0087ca; transform-origin: bottom right; transition: transform 0.25s ease-out; }.hover-underline-animation:hover:after { transform: scaleX(1); transform-origin: bottom left; }
 <h2 class="hover-underline-animation">text with underline animation</h2>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM