JavaScript:点击的链接应该以一种壮观的方式消失
我编写了一个 PHP/PostgreSQL/Oracle 脚本供工作中内部使用,其中链接显示为浅蓝色“标签”,也可以通过单击它们附近的“x”来隐藏:
到目前为止,效果非常好,我的同事们已经印象深刻。
我从 Stackoverflow 偷来的“标签”的 CSS 外观(因为我自己的 CSS/JS 技能非常有限,而且模仿是最真诚的奉承):
a.hide {
color:#3E6D8E;
background-color: #E0EAF1;
border-bottom: 1px solid #3E6D8E;
border-right: 1px solid #7F9FB6;
padding: 3px 4px 3px 4px;
margin: 2px 2px 2px 0;
text-decoration: none;
font-size: 90%;
line-height: 2.4;
white-space: nowrap;
}
a.hide:hover {
background-color: #e7540c;
color: #E0EAF1;
border-bottom: 1px solid #A33B08;
border-right: 1px solid #A33B08;
text-decoration: none;
}
a.tag {
color:#3E6D8E;
background-color: #E0EAF1;
border-bottom: 1px solid #3E6D8E;
border-right: 1px solid #7F9FB6;
padding: 3px 4px 3px 4px;
margin: 2px 2px 2px 0;
text-decoration: none;
font-size: 90%;
line-height: 2.4;
white-space: nowrap;
}
a.tag:hover {
background-color: #3E6D8E;
color: #E0EAF1;
border-bottom: 1px solid #37607D;
border-right: 1px solid #37607D;
text-decoration: none;
}
现在我想增强我的通过几行 JavaScript 编写脚本,当用户点击“标签”附近的“x”时,使“标签”以一种有趣的方式消失(当然,链接应该仍然有效)。也许让它们飞起来甚至爆炸?有人在这里有想法或者可以分享一个好技巧吗?
我不想使用 jQuery,因为我还没有学会它。
谢谢你,我希望你的创造力:-) 亚历克斯
I've programmed a PHP/PostgreSQL/Oracle script for internal usage at my work, where links are displayed as light-blue "tags", which can also be hidden by clicking an "x" near them:
This works pretty well sofar and my colleagues are already impressed.
The CSS-appearance for the "tags" I have stolen from Stackoverflow (since my own CSS/JS skills are very limited and also Imitation is the sincerest form of flattery):
a.hide {
color:#3E6D8E;
background-color: #E0EAF1;
border-bottom: 1px solid #3E6D8E;
border-right: 1px solid #7F9FB6;
padding: 3px 4px 3px 4px;
margin: 2px 2px 2px 0;
text-decoration: none;
font-size: 90%;
line-height: 2.4;
white-space: nowrap;
}
a.hide:hover {
background-color: #e7540c;
color: #E0EAF1;
border-bottom: 1px solid #A33B08;
border-right: 1px solid #A33B08;
text-decoration: none;
}
a.tag {
color:#3E6D8E;
background-color: #E0EAF1;
border-bottom: 1px solid #3E6D8E;
border-right: 1px solid #7F9FB6;
padding: 3px 4px 3px 4px;
margin: 2px 2px 2px 0;
text-decoration: none;
font-size: 90%;
line-height: 2.4;
white-space: nowrap;
}
a.tag:hover {
background-color: #3E6D8E;
color: #E0EAF1;
border-bottom: 1px solid #37607D;
border-right: 1px solid #37607D;
text-decoration: none;
}
Now I would like to enhance my script by few JavaScript lines and make the "tags" disappear in an interesting way, when an "x" near them has been clicked by the user (the links should still work of course). Maybe make them fly up or maybe even explode? Does anybody have an idea here or can share a nice trick?
I'd prefer not to use jQuery, because I haven't learnt it yet.
Thank you and I hope for your creativity :-)
Alex
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
纯 javascript 淡出效果将是(目前对于非 IE 浏览器..)
演示:http://jsfiddle.net/gaby/AkA5C/
我已将标签和按钮包装在
中这样您就可以轻松地瞄准两者。
A pure javascript fadeout effect would be (for non-IE browsers at the moment..)
demo: http://jsfiddle.net/gaby/AkA5C/
I have wrapped the tag and button in a
<span></span>
so that you can easily target both.使用 jQuery 效果。非常简单而且看起来很酷
Use jQuery effects. Easy as hell and looks cool
我建议不要在你的应用程序中使用华丽的“爆炸”效果,最终用户使用你的应用程序是因为它解决了一个没有展示的问题。如果你必须有效果,那就使用简单的效果。如果您必须使用此类效果,请使用不同的技术,例如闪光灯。
I advise not using flamboyant “explosive” effects in your app, at the end of the day users are use your app because it solves a problem not to get a show. If you must have effects, then use simple effects. If you MUST use such effects then use a different technology like flash.