[英]CSS 3 Animations with jQuery append()
I want to create something like this: JQuery Growl Nofitications . 我想创建这样的东西: JQuery Growl Nofitications 。 Because I am not very experienced with things like this, at first I create div that I append Bootstrap Alert notifications at the top of the page:
因为我对这样的事情不太熟悉,所以首先创建div,然后在页面顶部附加Bootstrap Alert通知:
<div id="notificationDiv" style="position: fixed; width: 90%"></div>
And I append to this div notifications: 我在此div通知后追加:
var that = this;
var uniqueId = new Number((new Date()).getTime());
this.messages.push({id: uniqueId,
message: this.createMessage(type, uniqueId, direction, size)});
$("#notificationDiv").append( (this.messages[this.messages.length - 1]).message );
$("#" + this.idPreffix + (uniqueId).toString()).click(function(){
that.messages.splice(this._findByUniqueId($(this).prop("id").split("_")[1]), 1);
$(this).remove();
});
setTimeout(function(){
that.messages.splice(
that._findByUniqueId($("#" + that.idPreffix +
(uniqueId).toString()).prop("id").split("_")[1]), 1);
$("#" + that.idPreffix + (uniqueId).toString()).remove();
}, this.timeout);
And that's ok, it works - for example when I click button nofitication appears at the top of the page and is ,,fixed". I want to animate add/remove notification, then I extend (i don't know if that's way is good) Bootstrap's alert class: 没关系,它可以正常工作-例如,当我单击按钮时,nofitication出现在页面顶部,并且固定为“。我想为添加/删除通知设置动画,然后扩展(我不知道这是良好)的Bootstrap警报类:
.alert{
-webkit-animation-duration: 3s;
-webkit-animation-name: slide-in;
-webkit-animation-iteration-count: infinite;
}
@-webkit-keyframes slide-in{
from{
margin-left: 100%;
width: 300%;
}
to{
margin-left: 0%;
width: 100%
}
}
To achieve something like I saw in Mozilla Developer Network: Using CSS animations . 要实现我在Mozilla开发人员网络中看到的功能: 使用CSS动画 。 I add -webkit- prefix because at first I want to do it for my browser, Opera 24 and as I saw in "Can I Use: CSS3 Animation" I have to add it.
我添加-webkit-前缀是因为起初我想在我的浏览器Opera 24中使用它,并且正如我在“我可以使用:CSS3动画”中看到的那样,我必须添加它。 But it doesn't work, and because I am very new to non-primitive CSS, I have no idea why and how I can improve it.
但这是行不通的,并且因为我对非原始CSS还是很陌生,所以我不知道为什么以及如何改进它。 I will be very happy if anybody decides to help me - thank in advance for each answer.
如果有人决定帮助我,我将非常高兴-预先感谢每个答案。
PS Intentionally I don't want to use JQuery animations or things like that - the idea is that it should be as far as I can independent for external libraries like JQuery or Bootstrap (I know that I'm using Bootstrap classes, but it is very-very-very alpha version :) ). PS有意地我不想使用JQuery动画或类似的东西-想法是它应该尽可能地独立于JQuery或Bootstrap之类的外部库(我知道我正在使用Bootstrap类,但是它是非常非常alpha版本:))。
PS 2 Alert HTML from console.log: 来自console.log的PS 2 Alert HTML:
<div id='message_1411159143475' class='alert alert-success'
style ='float: left; width: 100%;'>
Operacja zakończona sukcesem!
<i style='margin-left: 5px !important' class='glyphicon glyphicon-ok-sign'></i>
</div>
Now I know why that's no working - because of my stupidity :) I had CSS code between <script type="text/css">...</script>
tags, instead correct tag <style type="text/css"></style>
- it should be , not :) Now there is another problem - it animates when it shows, but not when it hides - but now it will be much easier to fix. 现在,我知道为什么它不起作用-由于我的愚蠢:)我在
<script type="text/css">...</script>
标记之间插入了CSS代码,而是正确的标记<style type="text/css"></style>
-应该是,而不是:)现在还有另一个问题-它在显示时动画,但在隐藏时不动画-但现在更容易修复。 This answer can be closed now. 该答案现在可以关闭。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.