简体   繁体   English

单击css3动画

[英]css3 animation on click

The following zip contains the website html and required files: http://dl.getdropbox.com/u/4281191/login.zip 以下zip包含网站html和必需的文件: http : //dl.getdropbox.com/u/4281191/login.zip

When you hover the html (html:hover) you see a animation that transforms the container into a loginbox, I want that to happen when I click on "Login" at the "Hello, Guest" menu instead. 当您将鼠标悬停在html(html:hover)上时,您会看到一个动画,将容器转换为登录框,我希望当我在“ Hello,Guest”菜单上单击“ Login”时发生这种情况。

Anyway to get this done? 无论如何要做到这一点? I'm new to js... 我是js新手...

Additional info: 附加信息:

the css is inside the html, and the css3 animation gets triggered by: css在html内,并且css3动画由以下方式触发:

html:hover id/class {
    property: value;
}

Thanks for any help! 谢谢你的帮助! And I can't vote at comments since I don't have enough reputation...but I could do some free design work for the person who helps me ^^ 而且由于我没有足够的声誉,我无法对评论进行投票...但是我可以为帮助我的人做一些免费的设计工作^^

I still don't know much about animations, but for what matters here, you could use something like the .classname:active or .classname:focus selectors. 我对动画还是不太了解,但是对于这里重要的事情,您可以使用.classname:active或.classname:focus选择器之类的东西。 But as soon as you click something inside it (eg a text box), the style will disappear. 但是,只要单击其中的某些内容(例如文本框),样式就会消失。

So, for this, it really depends. 因此,这确实取决于。 Do you just want a menu that has links that take the user to another page (for this case, you'll be fine) or do you want a login form (for this case, forget it, use jquery)? 您是否只需要一个菜单​​,该菜单具有将用户带到另一个页面的链接(在这种情况下,您会没事的)还是想要登录表单(在这种情况下,请忘记它,使用jquery)?

For today and future reference, save this link because it'll be your best friend: 对于今天和将来的参考,请保存此链接,因为它将是您最好的朋友:

http://www.w3.org/TR/selectors/#selectors http://www.w3.org/TR/selectors/#selectors

Update 更新资料

Yes, I hovered but I didn't look at the code. 是的,我徘徊了,但是我没有看代码。 I looked now and, unfortunately, the answer is no. 我现在看了,不幸的是,答案是否定的。 You can't affect some upper level object like that using CSS. 您不能使用CSS来影响某些上层对象。

For that use jQuery. 为此,使用jQuery。 The simpler way would be use jQuery to add a class to the element you want to change (like $("#the-object-id").addClass('class-name')). 最简单的方法是使用jQuery向要更改的元素添加一个类(例如$(“#the-object-id”)。addClass('class-name'))。 To keep the effect add the duration argument. 为了保持效果,请添加duration参数。 Read this page about Adding a class using jQuery . 阅读此页面有关使用jQuery添加类

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM