html - 使用 css 和 HTML 的 streamlabs OBS 的简单文本删除效果

标签 html css window-resize

我想只使用 CSS 和 HTML 获得简单的文本删除效果,我有一个非常简单的代码。
我的目标是,当文本框缩小时文本不会调整大小,这就是我想要实现这种类型的文本删除效果的方式。请注意我需要一个完全透明的背景,因为我想将它用作 twitch 的子警报。 this type of wipe effect

是否有任何选项可以让文本保持在固定位置(右侧),并且当文本框从左到右删除它时。

.containner{
width: 200px;
height: 150px;
background-color:green;

overflow: hidden;
position: relative;

}
.innercon{
    right: 0%;
width: 200px;
height: 50px;
background-color: pink;
animation: animaitonx;
animation-duration: 5s;
animation-iteration-count: infinite;
overflow: hidden;
position: absolute;
/*animation-delay: 10s;*/

}
@keyframes animaitonx{
    from{
        width: 200px;

    }
    to{
        width:0px;

    }
}
#copy{
    position: static;
}
.texttHolder{
     
    width:200px;
    text-align: right;
    
    color:red
}
<body onload="mainx()">
<div id="containner" class="containner">
    <div class="innercon">
        <div class="texttHolder" id="copy">
            here is your text
        </div>
        <div id="paste">
            
        </div>
    </div>


</div>


</body>

最佳答案

一个简单的 mask 效果就可以做到:

h1 {
  color: #fff;
  display: table;
  margin: 50px auto;
  font-family: sans-serif;
  font-size: 60px;
  -webkit-mask-image: linear-gradient(to right, transparent 40%, #fff 60%);
  -webkit-mask-position: right;
  -webkit-mask-size: 250% 100%;
  animation: hide 2s linear forwards;
}

h1.opposite {
  -webkit-mask-image: linear-gradient(to left, transparent 40%, #fff 60%);
  animation-direction: reverse;
}

@keyframes hide {
  to {
    -webkit-mask-position: left;
  }
}

body {
  background: linear-gradient(to right, red, green);
}
<h1>A sample text</h1>

<h1 class="opposite">A sample text</h1>

关于html - 使用 css 和 HTML 的 streamlabs OBS 的简单文本删除效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65661602/

相关文章:

html - 更改 Bootstrap 中的行高

javascript - 如何将底部 float 的非菜单内容添加到语义用户界面菜单

c++ - Windows下免费商用框架中ViewBox的替换

java - 为什么我的 Java swing 应用程序行为异常?

php - 如何删除 DOM 元素标签但保留其内容?

javascript - 如何使 Bootstrap 行靠得更近?

jquery - 复制和粘贴渲染脚本被破坏?

html - Firefox contentEditable div 焦点问题

html - 使 flex 元素在一行中具有相等的宽度

javascript - 在此 javascript-jquery 函数中添加 resizeWindow