简体   繁体   English

当我启用CSS动画时,jQuery hide()。slideDown()不起作用

[英]jQuery hide().slideDown() does not work when I have CSS animations enabled

I'm new to this. 我是新来的。

I used jQuery to make three divs (buttons) slideDown at page load. 我使用jQuery在页面加载时制作了三个div(按钮)slideDown。 Then I made them expand a little (downwards) when mouseover'd. 然后,当鼠标悬停在上面时,我使它们扩展一点(向下)。 This worked well in Safari but not in Firefox. 这在Safari中效果很好,但在Firefox中效果不好。 So I changed around a few things. 所以我改变了几件事。

Now I have CSS animations to make them expand on hover and a jQuery function to make them slideDown on load. 现在,我具有CSS动画(使它们在悬停时扩展)和jQuery函数(使它们在加载时滑动)。 But this slideDown doesn't seem to work properly. 但是此slideDown似乎无法正常工作。

HTML: HTML:

<div class="header">
    <div class="button_container">
        <a href = "../index.htm"><div class="header_button home_button">Back to Home</div></a>
        <a href = "../Projects/projects.htm"><div class="header_button projects_button">Projects</div></a>
        <a href = "../Resume/resume.htm"><div class="header_button resume_button" >Resume</div></a>
    </div>
</div>

CSS: CSS:

.header_button {
    display: inline-block;
    height: 130px;
    line-height: 130px;
    width: 300px;
    background-color: lightgrey;
    color: black;
    box-shadow: 0 0 10px;
    -moz-transition: 0.5s all ease-in-out;
    -ms-transition: 0.5s all ease-in-out;
    -webkit-transition: 0.5s all ease-in-out;
    -o-transition: 0.5s all ease-in-out;
}

.header_button:hover {
    background-color: lightyellow;
    height: 140px;
    -moz-transition: 0.5s all ease-in-out;
    -ms-transition: 0.5s all ease-in-out;
    -webkit-transition: 0.5s all ease-in-out;
    -o-transition: 0.5s all ease-in-out;
}

Some of the stuff has been copy-pasted from all over Stack Overflow. 有些内容已从整个Stack Overflow复制粘贴。 But now I've got the hover-expand thing working. 但是现在我有了悬停扩展功能。

jQuery: jQuery的:

$(document).ready(function() {
    $('.header_button').hide().slideDown('slow');
});

Convenient jsFiddle. 方便的jsFiddle。

Updated Fiddle 更新小提琴

Check this code, 检查此代码,

$(document).ready(function() {
    $('.header_button').parent().hide().slideDown('slow');
});

Though you hide .header_button it has parent <a> which is still visible. 尽管您隐藏了.header_button但它的父<a>仍然可见。

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

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