zoukankan      html  css  js  c++  java
  • jQuery-slideDown向下滑,slideUp向上滑,slideToggle滑动

    1.基本概念

    • slideDown() 向下滑动,显示
    • slideUp() 向上滑动,隐藏
    • slideToggle() 滑动切换

    2.代码如下

    滑动展示

    <!DOCTYPE html>
    <html lang="en">
    
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>滑动动画</title>
        <style>
            #box {
                 300px;
                height: 200px;
                border: 1px solid #000;
                background-color: #ccc;
            }
        </style>
    </head>
    
    <body>
        <button id="show">显示</button>
        <button id="hide">隐藏</button>
        <button id="toggle">切换</button>
        <div id="box">文字</div>
        <script src=" https://cdn.bootcss.com/jquery/3.5.0/jquery.min.js"></script>
        <script>
            $("#show").click(function() {
                $("#box").slideDown(1500)
            })
            $("#hide").click(function() {
                $("#box").slideUp(1500)
            })
            $("#toggle").click(function() {
                $("#box").slideToggle(1500)
            })
        </script>
    </body>
    
    </html>
    

    滑动应用

    <!DOCTYPE html>
    <html lang="en">
    
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>滑动导航</title>
        <style>
            ul {
                list-style: none;
            }
            
            li {
                 240px;
                font-size: 14px;
                padding: 15px 20px;
            }
            
            li:hover {
                background-color: #ecf5ff;
            }
            
            #subNav {
                display: none;
                 200px;
            }
        </style>
    </head>
    
    
    <body>
        <div id="nav">
            <ul class="list">
                <li>导航1
                    <ul class="subNav">
                        <li>选项1</li>
                        <li>选项2</li>
                    </ul>
                </li>
                <li>导航2
                    <ul class="subNav">
                        <li>选项1</li>
                        <li>选项2</li>
                    </ul>
                </li>
                <li>导航3
                    <ul class="subNav">
                        <li>选项1</li>
                        <li>选项2</li>
                    </ul>
                </li>
            </ul>
        </div>
    </body>
    <script src=" https://cdn.bootcss.com/jquery/3.5.0/jquery.min.js"></script>
    <script>
        $(".list>li").click(function() {
            $(this).find('.subNav').slideToggle()
        })
    </script>
    
    </html>
    

    滑动应用

    <!DOCTYPE html>
    <html lang="en">
    
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>从底部显示文字</title>
        <style>
            * {
                margin: 0;
                padding: 0;
            }
            
            #box {
                 200px;
                height: 240px;
                border: 1px solid #000;
                position: relative;
                margin: 0 auto;
            }
            
            .bottomShow {
                border: 1px solid red;
                position: absolute;
                bottom: 0px;
                left: 0px;
                display: none;
            }
        </style>
    </head>
    
    <body>
        <div id="box">
            <p>产品</p>
            <p class="bottomShow">我爱你</p>
        </div>
        <script src=" https://cdn.bootcss.com/jquery/3.5.0/jquery.min.js"></script>
        <script>
            $("#box").mouseover(function() {
                $(".bottomShow").slideDown(1000)
            })
            $("#box").mouseout(function() {
                $(".bottomShow").slideUp()
            })
        </script>
    </body>
    
    </html>
  • 相关阅读:
    BizTalk2010简介
    各大类库的类工厂
    全国城市三级级联菜单(java+Ajax+jQuery)
    gcc编译系统
    通用排行榜组件
    本地化中文示例代码需求调查
    PortalBasic Java Web 应用开发框架(源码、示例及文档)
    FFLIB 框架
    ORM/IOC框架设计感悟
    个人日记
  • 原文地址:https://www.cnblogs.com/dongxuelove/p/12933631.html
Copyright © 2011-2022 走看看