我有一个动画的问题,我希望过渡只发生一次,或者在两面都看不到.文本停在中间或边上,试图更改背景位置-它也不起作用

 <div class="content">
        <p> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s</p>
        </div>
 .content p{
    font-size: 20px;
    line-height: 35px;
    font-weight: bold;
    font-family: sans-serif;
    cursor: pointer;

}
.content p{
    background: linear-gradient(to right, white, hsl(0, 0%, 0%) 10%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shine 2s infinite linear;

}

@keyframes shine {
  0% {
    background-position: 0;
  }
  60% {
    background-position: 600px;
  }
  100% {
    background-position: 600px;
  }
}

推荐答案

使用Reza的代码,我可以略微修改".content div",将"动画:闪耀2.5s无限"更改为"动画:闪耀2.5s 1;",将"左"更改为"-100px".

  .content {
  position: relative;
  overflow: hidden;
  width: 600px;
}

.content p {
  font-size: 20px;
  line-height: 35px;
  font-weight: bold;
  font-family: sans-serif;
  cursor: pointer;
}

.content div {
  position: absolute;
  top: 0;
  height: 100%;
  left: -100px;
  width: 30%;
  background: linear-gradient(to right, white, transparent 50%);
  -webkit-text-fill-color: transparent;
  animation: shine 2.5s 1;
  overflow: hidden;
}

@keyframes shine {
  0% {
    left: -10%;
  }
  100% {
    left: 110%
  }
<div class="content">
  <p> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s</p>
  <div>
  </div>
</div>

https://jsfiddle.net/jasonbruce/1gdx706t/1/

Html相关问答推荐

html中背景色的全单元格R中的Rmarkdown表

CSS位置:固定尊重母公司的保证金属性.""'为什么?

Angular 滑块问题

如何通过扭曲元素来倾斜元素?

MatSnackBar: colored颜色 不起作用

如果浏览器通过http接收html,为什么客户端内置表单验证不起作用?

如何创建剪切到路径的循环文本字幕?

如果DIV没有特定的sibling 姐妹,则以CSS为目标

类型';联系人组件';上不存在属性';name FormControl';

CSS中的转换属性是如何工作的?

高度:适合-内容不拉伸以适合内部长度

如何使用css创建六边形棋盘?

Swift WKUserContentController 和 WKScriptMessageHandler 设置不正确

下划线在 Bootstrap 5 导航链接下无法正常工作

在选项标签中如何添加Django模板的条件

如何使用 CSS 应用带有笔划的文本阴影?

Mediawiki css/html 信息框创建空白行

Primeng浮动标签溢出管理

使用 htmloutput 在shiny 的应用程序中呈现文本

如何在锚点可点击的伪元素周围制作空白?