[英]How to Slide an Element In and Out of a Div
I'm trying to get better at JS and CSS, so I'm making a fake iPhone and am trying the simulate the look of when a text bubble pops on and off screen. 我试图在JS和CSS上做得更好,所以我在制造假冒的iPhone,并尝试模拟在屏幕上和屏幕外弹出文本气泡时的外观。 This is what it looks like so far, and this is the HTML for the phone itself:
这是到目前为止的样子,这是手机本身的HTML:
<div id="iPhone">
<div id="screen"></div>
<div id="me" class="bubble"></div>
<div id="homeButton" class="circle"></div>
</div>
As well as the style sheet: 以及样式表:
#iPhone {
position: fixed;
width: 250px;
height: 500px;
background-color: black;
border-radius: 25px;
top: 50%;
right: 30%;
transform: translate(-50%, -50%);
-webkit-filter: blur(3px);
box-shadow: 0 0 40px 20px white;
border: solid 2px white;
}
#me {
background-color: #1D62F0;
margin-top: 130%;
margin-left: 25%;
}
#me::after{
content: "";
position: absolute;
right: 0em;
bottom: 0;
width: 0.5em;
height: 1em;
border-left: 0.5em solid #1D62F0;
border-bottom-left-radius: 1em 0.5em;
}
#screen {
position: fixed;
width: 241px;
height: 370px;
background-color: white;
border-radius: 0px;
top: 8%;
left: 1%;
-webkit-filter: blur(3px);
border: solid 2px black;
}
Right now, there's no JS governing it. 现在,没有JS来管理它。 How do I make it naturally slide onto the "screen" div and then disappear off the top, just like a real text message?
如何使其自然滑动到“屏幕” div上,然后像真实文本消息一样从顶部消失?
Thanks! 谢谢!
您需要将overflow: hidden
属性放在消息容器div上,然后将新的消息框推入已存在的消息框下方,以便它们最终消失。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.