如何在css3中永久使一个元素可见?

huangapple go评论72阅读模式
英文:

How do I permanently make an element visible in css3?

问题

I'm trying to create a text-based game that a user will only read at the beginning.

然后我的按钮叫做 "begin",显示在最后,但问题是它逐渐消失,用户将无法再看到它,因为它被隐藏了

我尝试使用名为 fadeIn 的动画使其可见。

#message_.active h1.five{
    position: relative;
    opacity: 0;
    animation: fadeIn 10s linear;
    animation-delay: 53s;
    font-family: 'Edu SA Beginner', cursive;
    top: 50px;
    left: 160px;
    cursor: pointer;
}

@keyframes fadeIn {
 0%,100% { opacity: 1 }
}
<div id="message_" class="active">
  <h1 class="five">text</h1>
</div>
英文:

I'm trying to create a text-based game that a user will only read at the beginning.

and then my button which is called "begin" shows up at the end but the problem is that it fades away and the user will not be able to see it anymore because its hidden

I tried using the animation titled fadeIn to make it visible.

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->

#message_.active h1.five{
    position: relative;
    opacity: 0;
    animation: fadeIn 10s linear;
    animation-delay: 53s;
    font-family: &#39;Edu SA Beginner&#39;, cursive;
    top: 50px;
    left: 160px;
    cursor: pointer;
}

@keyframes fadeIn {
 0%,100% { opacity: 1 }
}

<!-- language: lang-html -->

&lt;div id=&quot;message_&quot; class=&quot;active&quot;&gt;
  &lt;h1 class=&quot;five&quot;&gt;text&lt;/h1&gt;
&lt;/div&gt;

<!-- end snippet -->

答案1

得分: 4

animation-fill-mode : forwards;
position            : relative;
opacity             : 0;
animation           : fadeIn 10s linear;
animation-fill-mode : forwards;
animation-delay     : 2s;
font-family         : 'Edu SA Beginner', cursive;
top                 : 50px;
left                : 160px;
cursor              : pointer;
<div id="message_" class="active">
  <h1 class="five">text</h1>
</div>
英文:

with a little effort you could have found this on your own...

animation-fill-mode : forwards;

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->

#message_.active h1.five{
  position            : relative;
  opacity             : 0;
  animation           : fadeIn 10s linear;
  animation-fill-mode : forwards;
  animation-delay     : 2s; /* why waiting 53s for a test code to start ? */
  font-family         : &#39;Edu SA Beginner&#39;, cursive;
  top                 : 50px;
  left                : 160px;
  cursor              : pointer;
}

@keyframes fadeIn {
  0%   { opacity: 0 }
  100% { opacity: 1 }
  }

<!-- language: lang-html -->

&lt;div id=&quot;message_&quot; class=&quot;active&quot;&gt;
  &lt;h1 class=&quot;five&quot;&gt;text&lt;/h1&gt;
&lt;/div&gt;

<!-- end snippet -->

huangapple
  • 本文由 发表于 2023年7月31日 19:17:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/76803095.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定