-8
A
回答
0
你可以試試這個
.container {
width: 100vw;
height: 100vh;
background: lightblue;
position: relative;
}
.popup {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 200px;
height: 200px;
background: white;
opacity: 0;
animation: popup .5s 5s ease forwards;
}
@keyframes popup {
from {opacity: 0; }
to{opacity: 1; }
}
<div class="container">
<div class="popup">Popup</div>
</div>
-1
0
它只能與CSS,採用動畫和複選框來完成hack
我建議你將來嘗試自己做,至少要發佈你已經嘗試過或者一些示例代碼。這不是一個代碼製作網站。我們幫助您找到解決方案,但我們需要看到您嘗試了一些方法。
無論如何,我有一些空閒時間,並想幫助你。但是這不會經常發生在SO
所以它就是這樣。使用silibing選擇(+, - ),CSS動畫和複選框,點擊黑客
見下
body {
margin: 0
}
input:checked,
input:checked + .popMe,
input:checked ~ .overlay {
display: none;
}
input {
position: fixed;
right: 15px;
top:30%;
opacity: 0;
animation-name: justopac;
animation-delay: 1s;
animation-duration: 0.3s;
animation-fill-mode: forwards;
animation-timing-function: ease-out;
z-index: 2;
}
.popMe {
height: 150px;
width: 150px;
left: 50%;
top: 50%;
transform: scale(0) translate(-50%, -50%);
position: fixed;
background: red;
animation-name: popMe;
animation-delay: 1s;
animation-duration: 0.3s;
animation-fill-mode: forwards;
animation-timing-function: ease-out;
transform-origin: left;
z-index: 2;
}
.overlay {
position: fixed;
animation-name: justopac;
animation-delay: 1s;
animation-duration: 0.3s;
animation-fill-mode: forwards;
animation-timing-function: ease-out;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.7);
opacity: 0;
}
@keyframes justopac {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@keyframes popMe {
0% {
transform: scale(0) translate(-50%, -50%);
}
100% {
transform: scale(1) translate(-50%, -50%);
}
}
<input type="checkbox">
<div class="popMe">
<p>
This is a popup
</p>
</div>
<div class="overlay">
</div>
<div class="content">
Lorem ipsum dolor sit amet, curabitur eu a duis vitae odio, ac consectetuer conubia at, donec ante aliquam at, placerat neque leo, ac turpis accumsan. Aenean viverra pellentesque aliquet, tincidunt dolor consequat lorem dolorum mauris, amet bibendum sed
lacus, sapien duis nullam. Pellentesque nunc laoreet id egestas integer ac. Proin dis tristique sodales mollis incididunt. Est phasellus elit libero, fermentum suspendisse enim convallis mauris sed vulputate, ac aliquam integer quis consectetuer pellentesque,
wisi urna velit pharetra pellentesque, dictum velit nec metus vitae. Neque tincidunt nec, eu et ligula etiam sit aliquam wisi. Cupiditate scelerisque ipsum pellentesque maecenas quam, ipsum nec augue suscipit, tincidunt mi ac ut risus urna tristique.
Fermentum vel eros, posuere convallis. Est lectus morbi leo mollis, pede nihil pharetra venenatis, sit est fermentum.
</div>
0
您可以使用CSS動畫,使div的刻度0在第5秒後頁面加載,然後5秒後它會自動更改爲比例1,因爲它是默認比例值
@keyframes pop
{
0%{transform:scale(0);}
100%{transform:scale(0);}
}
<div style="animation: pop 5s;">this div will be shown exactly 5s after page load</div>
+0
雖然這段代碼片段可以解決這個問題,[包括解釋](http://meta.stackexchange.com/questions/114762 /解釋 - 完全基於代碼的答案)真的有助於提高你的文章的質量。請記住,您將來會爲讀者回答問題,而這些人可能不知道您的代碼建議的原因。 – doydoy
相關問題
- 1. 我需要在一段時間後關閉彈出窗口
- 2. 日期彈出模塊 - 我也想要一個時間彈出窗口
- 3. 模態彈出框在一段時間後隱藏()
- 4. 一段時間後的JavaScript彈出停止
- 5. 彈出一個特定的時間後彈出關閉自動
- 6. 我想要jgrowl只會在登錄後彈出一次
- 7. jQuery的顯示功能,在一段時間內淡出彈出
- 8. Javascript在某段時間後關閉彈出窗口
- 9. 想要在經過一段時間後第二個顯示數字
- 10. 想要在getJson調用之前預載圖像一段時間
- 11. 想要添加一個字段到DATE_ADD的時間戳
- 12. 如何在用戶進入asp.net網站一段時間後生成彈出框
- 13. Android:如何在點擊畫布一段時間後顯示彈出對話框
- 14. 我不想$ _SESSION的很長一段時間後停止
- 15. 想要在同一時間中的R
- 16. 一段時間後彈簧啓動高內存使用
- 17. 時間fancybox彈出
- 18. Junit想要在一定的時間後停止方法
- 19. 想要一個NPC根據當天的時間做出反應
- 20. FFMPEG:在創建時間戳後的一段時間後輸出到新文件?
- 21. NSDateFormatter:我不想要時間!
- 22. Eclipse一段時間後出現錯誤,出現java錯誤
- 23. 前後一段時間後,爲
- 24. 如何隱藏時間後彈出一個Java中逝去/ GWT
- 25. 想要在ASP.net中的時間間隔後調用函數
- 26. div出現後消失一段時間,並徘徊時apears ...
- 27. 想要創建一個可編輯的彈出框
- 28. 想要使用休眠彈出一些值從MySQL數據庫
- 29. 想要在scala中創建一個彈出框
- 30. 在一段時間後超時NSThread
這對於CSS來說是不可能的。 – Jer
顯示一些元素後延遲你最常用的JavaScript或jQuery的 – aidinMC
你可以去CSS3動畫,使用動畫延遲屬性這裏是鏈接https://www.w3schools.com/css/css3_animations.asp –