使用jQuery的
似乎默认的隐藏动画方向是向左滑动,尽管这种行为在
我需要有选择地让框也向右滑动或向上滑动。
同样重要的是,如果这种行为没有定义,我担心不同的浏览器可能会以不同的方式呈现动画。因此,我也希望确保一致性。
滑动到左侧的行为在哪里定义?切换到向右滑动或向上滑动的最简单方法是什么?
hide()
函数和可选的持续时间参数,我能够让网站上的一些警报框优雅地滑出屏幕并消失。似乎默认的隐藏动画方向是向左滑动,尽管这种行为在
hide()
定义页面中没有定义。我需要有选择地让框也向右滑动或向上滑动。
同样重要的是,如果这种行为没有定义,我担心不同的浏览器可能会以不同的方式呈现动画。因此,我也希望确保一致性。
滑动到左侧的行为在哪里定义?切换到向右滑动或向上滑动的最简单方法是什么?
$(document).ready(function() {
$("#close-alert-box-urgent").click(function() {
$("#alert-box-urgent").hide(1000);
});
$("#close-alert-box-news").click(function() {
$("#alert-box-news").hide('fast');
});
});
.alert-box {
width: 50vw;
position: relative;
margin: 20px auto;
border: 1px solid black;
}
.alert-box-close {
position: absolute;
top: -12px;
right: -12px;
cursor: pointer;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js">
</script>
<article class="alert-box" id="alert-box-urgent">
<h1>Tuition Alert</h1>
<p>text text text text text text text text text text text text text text</p>
<a class="alert-box-close" id="close-alert-box-urgent">
<img src="http://i.imgur.com/czf8yas.png" height="25" width="25" alt="">
</a>
</article>
<article class="alert-box" id="alert-box-news">
<h1>Latest News</h1>
<p>text text text text text text text text text text text text text text</p>
<a class="alert-box-close" id="close-alert-box-news">
<img src="http://i.imgur.com/czf8yas.png" height="25" width="25" alt="">
</a>
</article>
fn.extend
的方法。让我来制作一个演示,看看它是否是一个好的解决方案。你可以使用@keyframes
来实现任何你想要的动画效果。 - Ricky Ruiz