博主信息
博文 40
粉丝 2
评论 1
访问量 46480
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
20.jQuery hover使用注意事项以及折叠框布局-2019年01月29号
万物皆对象
原创
940人浏览过

实例

<!DOCTYPE html>

<html>

<head>

    <meta charset="utf-8">

    <title>折叠盒子</title>

    <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>

    <style type="text/css">

        *{margin: 0; padding: 0;}

        li{

            list-style-type: none;

            width: 232px;

            height: 172px;

            background: lightblue;

            border-radius: 8px;

            position: relative;

            overflow: hidden;

            float: left;

            margin: 15px;

        }

        li img{

            width: 232px;

            height: 124px;

        }

        li a{

            text-decoration: none;

        }

        .title{

            background: blue;

            border-radius: 8px;

            width: 232px;

            height: 144px;

            position: absolute;

            top: 90px;

        }

        .total{

            background: green;

            border-radius: 8px;

            width: 232px;

            height: 42px;

            line-height: 42px;

            position: absolute;

            bottom: 0;

        }

        .total span{

            font-size: 12px;

            color: #fff;

        }

    </style>

<script type="text/javascript">

    $(document).ready(function(){

        $('a').hover(function(){

            // 这里注意事项:如果没有加find()方法无论你鼠标移入那个都好

            // 会导致全部'.title'有动画效果的,加上find()解决此问题

            $(this).find('.title').stop().animate({top:'30px'});

        },function(){

            $(this).find('.title').stop().animate({top:'90px'});

        });

    });

</script>

</head>

<body style="background:#ccc;">

        <ul>

            <li>

                <a href="" class="aa">

                    <img src="https://img.php.cn/upload/course/000/126/153/5aa23f0ded921649.jpg">

                    <div class="title" id="t">

                        <h3>内容1

                            <p>内容2</p>

                        </h3>

                    </div>

                    <div class="total">

                        <span>4153人在看</span>

                    </div>

                </a>

            </li>



            <li>

                <a href="">

                    <img src="https://img.php.cn/upload/course/000/126/153/5aa23f0ded921649.jpg">

                    <div class="title" id="t">

                        <h3>内容1

                            <p>内容2</p>

                        </h3>

                    </div>

                    <div class="total">

                        <span>3493人在看</span>

                    </div>

                </a>

            </li>

        </ul>

</body>

</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

6666.jpg

批改状态:合格

老师批语:下次记得给代码加上线上运行的功能
本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!
全部评论 文明上网理性发言,请遵守新闻评论服务协议
0条评论
作者最新博文
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号

  • 登录PHP中文网,和优秀的人一起学习!
    全站2000+教程免费学