垂直扩展图像菜单

时间:2012-10-08 10:59:01

标签: jquery html css menu

我想创建这个:http://tympanus.net/Tutorials/ExpandingImageMenu/

这个演示有一个教程,但它只有横向扩展。如何进行垂直扩展?

2 个答案:

答案 0 :(得分:1)

您在寻找Vertical Sliding Accordion吗?

Vertical Sliding Accordion

教程为here

答案 1 :(得分:0)

请查看下面的代码,它完全按照您提供的参考。

请注意: 请在此代码的head部分中包含jquery.com的jquery库(CDN)链接,以使其正常工作。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Horizontal Image Slider</title>

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

        $("ul#hslider li").click(function(){ 

            $(".context").hide("slow");                     //By default all divs are hidden
            $(".curtain").show("slow");                     //Curtains are on

            if($(this).hasClass("active"))
            {   
                $(this).removeClass("active");              //Remove class active       
                $(this).find("span.curtain").show("slow");  //Add Black Curtain
                $(this).find("div.context").hide("slow");   //Hide div content
            }
            else
            {
                $("ul#hslider li").removeClass("active");   //Remove active from all li's
                $(this).addClass("active");                 //Add class active
                $(this).find("span.curtain").hide("slow");  //Remove curtain        
                $(this).find("div.context").show("slow");   //Display div content
            }

            return(false);

        });

    });
</script>   
<style type="text/css">
body                                    { font-family:Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0; }
ul#hslider li                           { cursor:pointer; display:inline-block; list-style:none; padding:0; position:relative;vertical-align:top; }
ul#hslider li a img                     { float:left; height:100px; width:100px; }
ul#hslider li span.curtain              {   background:#000; 
                                            display:block; 
                                            height:100px; 
                                            left:0; 
                                            opacity:0.4; 
                                            filter:alpha(opacity=40); /* For IE8 and earlier */ 
                                            top:0; 
                                            position:absolute; 
                                            width:100px;  
                                        }
ul#hslider li .context                  { border:1px dashed #aaa; display:none; float:left; padding:10px; width:260px;  }
ul#hslider li .context p                { background:#eee; padding:5px; text-align:justify; }
</style>

</head>

<body>

<ul id="hslider">

<li>
    <a href="#"><img src="images/mysteryman.jpg" alt="mystery-man" title="MM" /></a>
    <span class="curtain">&nbsp;</span>
    <div class="context">

            <h2>Some Heading - 1</h2>

            <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. </p>

            <p>It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>

    </div>
</li>

<li>
    <a href="#"><img src="images/mysteryman.jpg" alt="mystery-man" title="MM" /></a>
    <span class="curtain">&nbsp;</span>
    <div class="context">

            <h2>Some Heading - 2</h2>

            <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. </p>

            <p>It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>

    </div>
</li>

<li>
    <a href="#"><img src="images/mysteryman.jpg" alt="mystery-man" title="MM" /></a>
    <span class="curtain">&nbsp;</span>
    <div class="context">

            <h2>Some Heading - 3</h2>

            <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. </p>

            <p>It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>

    </div>
</li>


</ul>

</body>
</html>