滑动面板按钮问题

时间:2010-11-21 12:12:56

标签: html css css3

我有一个html页面,它有一个SEARCH按钮,所以当我点击按钮时,面板也会随按钮一起向下滑动,但它不能正常工作。按钮停留在那里,这不是我想要的。我希望按钮随面板一起向下,然后也可以使用面板。

以下是我从中获取代码并希望完全相同的网站 http://csscody.com/demo/demo-slide-panel-in-jquery/

这是代码。

    <!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>
       <title></title>
       <script src="js/jquery-1.3.2.js" type="text/javascript"></script>
     <style type="text/css">        
       #panel 
       {
           position: absolute;
           background-color: #F0FEDC;
           height: 200px;
           display:none;
           border: 1px solid #000;
           z-index: 2;
    }

    #panel h2, p{
    margin:0px; padding:0px; padding-top:20px; padding-left:20px; color:#666

    }
    .slide 
    {
        position:relative;
        margin: 0;
        padding: 0;
        border-top: solid 4px #2b5386;
        background: url(../images/btnslider.png) no-repeat center top;
        z-index:2;
    }
    .btn-slide {  
        /*(background: url(white-arrow.gif) no-repeat right -50px;*/
        text-align: center;
        width: 144px;
        height: 31px;
        padding: 3px 10px 0 0;
        margin: 0 auto;
        display: block;
        font: bold 60%/60% Arial, Helvetica, sans-serif;
        color: #fff;
        text-decoration: none;
        z-index:2;
      }  
    .active {
        background-position: right 12px;
    }

    </style>  

     </head>

    <body>
         <div id="outside" style="border: 1px solid #dcdada; width: 929px; height:483px; position:absolute; top:128px; margin-left:1px">    
         <div id="panel">

    <h2>Slide Panel Heading</h2>
    <p>This is Jquery Example of Slide Panel. sample text(One of the most significant elements of a good user interface is visibility of the system’s status. Users must notice immediately what’s going on behind the scenes and whether their actions have actually led to the expected results. To achieve a more sophisticated level of system visibility, Web applications these days use AJAX (of course),)</p>
    <p><strong>Visit more Examples:</strong> <a href="http://www.csscody.com" style="color:#4C6E1E">www.csscody.com</a></p>

    <p class="slide"> <a href="#" class="btn-slide">Search</a></p></div>
    <div id="wrapper" style="width: 900px; height:473px; position: relative; top: -10px; left:4px">  

        <div style="position:relative; z-index:1">   
             <p> 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>
     </div>  
     </div> 
       <script type="text/javascript" language="javascript"> 
        var $ = jQuery.noConflict();  
          $(document).ready(function () {  
          $(".btn-slide").click(function () {
              $("#panel").slideToggle("slow");
              $(this).toggleClass("active"); return false;
          });


      });
    </script>

</body>
</html>

2 个答案:

答案 0 :(得分:0)

1)在id标记script

之前的</div>外面的<p class="slide"> <a href="#" class="btn-slide">Search</a></p>关闭div

2)取出display:none 在div面板中,因为你有<p>,所以<p>也不会出现,因为它是这个div的孩子。

将{{1}}放在id为div的div之后并测试它。

答案 1 :(得分:0)

完成它...我不得不将面板位置更改为“相对”并设置面板并将div顶部位置滑动到-500,最后整个PANEL div在包装div之外:)不得不专注于我的css为解决方案。感谢您的支持。 - 你