gpt4 book ai didi

javascript - Whatsapp 事件聊天列表项动画

转载 作者:行者123 更新时间:2023-11-29 23:16:06 25 4
gpt4 key购买 nike

我想知道是否有一种创建动画的简单方法,类似于 Whatsapp 的方法。

当您在聊天屏幕上并返回聊天列表时,事件元素会暂时以灰色突出显示(因此它显示之前打开的聊天)。

在 JS 或 CSS 中没有复杂的方法吗?希望你们中的大多数人都知道我在说什么。不幸的是在网上找不到任何例子......

最佳答案

这是一个如何实现该效果的示例,但由于没有关于您的元素的更多详细信息,我无法做更多的事情。

var li = $('li');
var messages = $('.messages');
var close = $('.close');

li.on('click', function(){
$(this).addClass('active');
messages.addClass('active');
});

close.on('click', function(){
messages.removeClass('active');
li.removeClass('active');
});
html,
body {
margin: 0;
padding: 0;
font-family: sans-serif;
}

.info {
margin-bottom: 20px;
padding-left: 15px;
}

ul {
list-style: none;
padding: 0;
margin: 0;
}

li {
background: #ececec;
padding: 10px;
border-bottom: 2px solid black;
cursor: pointer;
transition: background .2s .3s;
}


li.active {
background: gray;
transition: background .3s;

}

.messages {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: white;
transition: transform .3s;
transform: translateX(100%);
padding: 20px;
}

.messages.active {
transform: translateX(0);
}

.close {
display: inline-flex;
justify-content: center;
align-items: center;
width: 30px;
height: 30px;
position: absolute;
right: 70px;
top: 30px;
background: black;
color: white;
border-radius: 50%;
font-size: 20px;
cursor: pointer;
}

.close:hover {
opacity: .7;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p class="info" >Click on a person, and close the discussion by clicking on the "X" to see the effect.</p>

<ul>
<li>Bob</li>
<li>Steven</li>
<li>Marie</li>
<li>Marc</li>
<li>Jack</li>
<li>Edouardo</li>
</ul>

<div class="messages">
A lot of messages bla bla ...

...

<span class="close">X</span>
</div>

关于javascript - Whatsapp 事件聊天列表项动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52728412/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com