CSS中文本阴影的动画效果

4

I have the following code where I do an animation in CSS moving a div. But I wanted to also animate the shadow of the text simulating somehow a weight for my text:

div#main {
    background-color: #2E2E2E;
}

div#lblCaption {
    margin-bottom: 0px;
    color: #C7C7C7;}
    
div#NodeCaptionContainer{     
    animation-duration: .7s;
    animation-name: fadeAndScale;
    animation-timing-function: cubic-bezier(0.22, 0.61, 0.36, 1);
}
@keyframes fadeAndScale {
    from {
        opacity: 0;
  transform: scale(.9, .9);
  text-shadow: 0 0 .75px rgb(255, 255, 255), 0 0 .75px rgb(255, 255, 255);
    }
    to {
        opacity: 1;
        transform: scale(1, 1);
  text-shadow: 0 0 .0px rgb(255, 255, 255), 0 0 .0px rgb(255, 255, 255);
    }
}
<div id="main">
  <div id="NodeCaptionContainer">
          <div id="lblCaption" class="pretty p-default p-thick p-pulse"><p class="noMargin">&nbsp;&nbsp;&nbsp;&nbsp;Node: 1:9 &nbsp;&nbsp;&nbsp;&nbsp; Type: Function &nbsp;&nbsp;&nbsp;&nbsp; Read: 480B &nbsp;&nbsp;&nbsp;&nbsp; Write: 1088B &nbsp;&nbsp;&nbsp;&nbsp; </p></div> 
  </div> 
</div>

问题是翻译的动画使用animation-timing-function平滑进行,但阴影没有。我想也让阴影过渡更加平滑。在CSS中有没有一种方法可以使阴影过渡变得更加平滑?

1个回答

1

https://jsfiddle.net/Liamm12/6d9p5uun/67/

NodeCaptionContainer中定义了text-shadow,并使用forwards以避免回到相同的NodeCaptionContainer代码,然后使用keyframes隐藏它。

div#main {
    background-color: #2E2E2E;
}

div#lblCaption {
    margin-bottom: 0px;
    color: #C7C7C7;}
    
div#NodeCaptionContainer{     
    -webkit-animation: fadeAndScale .7s ease-in-out forwards;
    animation: fadeAndScale .7s ease-in-out forwards;
    text-shadow: 0 0 .75px red, 0 0 .75px red;
}
@keyframes fadeAndScale {
    from {
        opacity: 0;
  transform: scale(.9, .9);
    }
    to {
        opacity: 1;
        transform: scale(1, 1);
  text-shadow: 0 0 0 rgb(255, 255, 255);
    }
}
<div id="main">
  <div id="NodeCaptionContainer">
          <div id="lblCaption" class="pretty p-default p-thick p-pulse"><p class="noMargin">&nbsp;&nbsp;&nbsp;&nbsp;Node: 1:9 &nbsp;&nbsp;&nbsp;&nbsp; Type: Function &nbsp;&nbsp;&nbsp;&nbsp; Read: 480B &nbsp;&nbsp;&nbsp;&nbsp; Write: 1088B &nbsp;&nbsp;&nbsp;&nbsp; </p></div> 
  </div> 
</div>


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接