CSS div定位和jQuery slideUp疯狂 [英] CSS div positioning and jQuery slideUp madness

查看:201
本文介绍了CSS div定位和jQuery slideUp疯狂的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

已解决查看下面的注释

<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

<script type="text/javascript">
$(document).ready(function() {

    $('#playlistToggle').click(function(event) {

        event.preventDefault();

        if($('#playlist').is(":hidden"))
        {
            $('#playlist').slideUp('medium');
        }

        else
        {
            $('#playlist').slideDown('medium');
        }

    });

});
</script>

<style type="text/css">
    #playlist_wrapper
    {
        bottom: 30px;
        height: 75px;
        overflow: hidden;
        position: fixed;
        width: 100%;
        background-color: yellow;
    }

        #playlist
        {
            background-color: #FF6633;
            border: 1px solid #666666;
            height: 75px;
            width: 920px;
            position: relative;
            bottom: 0;
            margin: 0 auto;
            visibility: hidden;
        }
</style>

</head>

<a href="#" id="playlistToggle">Toggle Playlist</a>

<div id="playlist_wrapper">
    <div id="playlist"></div>
</div>

当您点击按钮时,此脚本应该向上滑动播放列表div。但是,当你打它时,什么也没有发生。如果您更改:

This script is supposed to slide up the playlist div when you hit the button. However, nothing happens when you hit it. If you change:


if($('#playlist')。is(:hidden))

if($('#playlist').is(":hidden"))

To:


if($('#playlist') .is(:visible))

if($('#playlist').is(":visible"))

并将css #playlist visibility属性从hidden更改为display div向上滑动到顶部,向下滑动到底部,与我想要的相反。我在这里做错了什么?

And change the css #playlist visibility property from "hidden" to "display", then the div slides up to the top, and slides down to the bottom, the exact opposite of what I want it to do. What am I doing wrong here?

编辑:要澄清:我需要的播放列表div从开始隐藏,当我点击切换按钮。

To clarify: I need the playlist div to be hidden from the start, and then slide up when I hit the toggle button.

推荐答案

对象只有隐藏。

* They have a CSS display value of none.
* They are form elements with type="hidden".
* Their width and height are explicitly set to 0.
* An ancestor element is hidden, so the element is not shown on the page.

看起来 #playlist 的标准,因此选择器不匹配 #playlist 。你可以取消 .is(':hidden')部分并且到期吗?

It doesnt appear that #playlist meets any of those criteria so therefore the selector is not matching on the #playlist. Can you do away with the .is(':hidden') part and make due without it?

这篇关于CSS div定位和jQuery slideUp疯狂的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆