0
<!DOCTYPE html>
<html>
<head>
<script src="jquery.js"></script>
<script>
$(document).ready(function()
{
    $("a").click(function(){
        $("#bg").slideToggle(1000,function(){
            $("#content").hide('fast',function(){
                $("#content").load($(this).attr('href'),function(){
                    $("#bg").slideToggle(1000);
                }); 
            });
        });
    });
});
</script>

<style>
    nav ul li
    {
    display: inline;
    padding: 0px 20px;
    text-decoration: none;
    }

    #bg
    {
    transition: all 2s;
    background-color: gray;
    z-index:25;
    width: 100%;
    height: 0px;
    }

</style>

</head>

<body>

<div>

    <h2>DEMO</h2>

    <nav>

        <ul>
            <li><a href="first.html#content">First</a>
            <li><a href="second.html#content">Second</a>
            <li><a href="third.html#content">Third</a>
        </ul>

    </nav>

    <div id="all">

<div id="bg"></div>         
        <p id="content">banna third Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum. Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima. Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum.</p>


    </div>

</div>

</body>
</html>

我有两个像这样的其他 html 文件,其内容必须加载,好的部分是内容正在动态加载,但我希望它在窗帘(在这种情况下是背景灰色的第一个 div)落下并且应该隐藏时具有从用户的角度来看它何时发生。我尝试了多少我无法达到那种效果。

4

1 回答 1

0

div之后有一个关闭<div id="bg">,您可能并不打算放在那里(因为现在您的代码正在显示/隐藏一个空的 div)。

您还希望删除 CSS 中的height: 0pxfor #bg,因为这意味着您可以更有效地隐藏空 div。

有了这两个变化,这个小提琴开始显示一些第一个动画:http: //jsfiddle.net/PvPv3/

于 2012-12-31T18:02:55.663 回答