JavaScript和CSS3翻译y下拉
我有一个下拉div,它有一个打开/隐藏按钮,我想转换:translatey(-280px);
slide-up的div。
问题在不同的设备中,transform:translatey:translatey(-280px);
is不同的!有时它并没有完全上升,并且显示了一半的DIV!
如何在任何其他设备中完全滑动div?
CSS:
.slideUp {
-webkit-transform: translateY(-280px);
transform: translateY(-280px);
transition: transform 0.5s ease-out;
}
.slideDown {
-webkit-transform: translateY(0);
transform: translateY(0);
transition: transform 0.5s ease-out;
}
JavaScript:
$('#arrow-down').click(function() {
header.classList.remove("slideUp");
header.classList.add("slideDown");
$('#arrow-down').css('display', 'none');
$('#arrow-up').css('display', 'block');
});
$('#arrow-up').click(function() {
header.classList.remove("slideDown");
header.classList.add("slideUp");
$("#arrow-up").css("display", "none");
$("#arrow-down").css("display", "block");
});
I have a dropdown div that it have a open/hide button, I want to transform: translateY(-280px);
the div for slide-up.
the problem is in different devices, transform: translateY(-280px);
is different! and sometime it does not rise completely, and half of div is shown!!
how can I slide up div completely in any other devices?
css :
.slideUp {
-webkit-transform: translateY(-280px);
transform: translateY(-280px);
transition: transform 0.5s ease-out;
}
.slideDown {
-webkit-transform: translateY(0);
transform: translateY(0);
transition: transform 0.5s ease-out;
}
javascript:
$('#arrow-down').click(function() {
header.classList.remove("slideUp");
header.classList.add("slideDown");
$('#arrow-down').css('display', 'none');
$('#arrow-up').css('display', 'block');
});
$('#arrow-up').click(function() {
header.classList.remove("slideDown");
header.classList.add("slideUp");
$("#arrow-up").css("display", "none");
$("#arrow-down").css("display", "block");
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
下拉的下拉方式可与所有屏幕尺寸一起使用,您可以将其更改为单击而不是悬停。
The below way of dropdown works with all screen sizes, you can change it to open on click and not hover.