Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
134 views
in Technique[技术] by (71.8m points)

Presentation Image CSS - javascript

I would like to add an image that covers the main page of my website. This image should then disappear after a few seconds. I tried but the image takes the space of the elements under ruining everything. How can I do? Thank you!!!!`

I apologize if I have not immediately provided an example I simply tried to use CSS to make the image disappear

    #fadeout {
    opacity: 1;
    transition: 1s opacity;
    text-align: center;
    font-size:32px;
  }

  p {
    text-align: center;
  }

Then I tried to make the image disappear with javascript:

 window.onload = function() {
  window.setTimeout(fadeout, 3000); 

}

function fadeout() {
  document.getElementById('TEST').style.opacity = '0';
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Personally I would just do a quick css anim as a simple fake splash loader like;

@keyframes reveal {
 0% {opacity: 1;}
 75% {opacity: 1;}
 99% {opacity: 0;}
 100% {opacity: 0; display: none;}
}

#splash-loader {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  background: lightgray url('https://i.imgur.com/bX2Uk7C.jpg') no-repeat center;
  background-size: cover;
  opacity: 0;
  animation: reveal 6s ease forwards;
}


#spinner {
  height: 10rem;
  width: 10rem;
  margin: 5rem auto;
  border-radius: 50%;
  background-repeat: no-repeat;
  background-position: center center;
  background-color: rgba(255,255,255,.5);
  background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgaWQ9InNwaW4taWNvbiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2aWV3Qm94PSIwIDAgMTAw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MCAxODMgMCAwYzAgNi01IDExLTExIDExbC02OSAwYy0xIDAtMSAwLTEgMHoiIC8+PC9zdmc+);
}
<div id="splash-loader">
 <div id="spinner"></div>
</div>

<h2>Hey I'm your normal content, howdy</h2>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...