Blogger Information
Blog 40
fans 2
comment 1
visits 38808
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
20.jQuery hover使用注意事项以及折叠框布局-2019年01月29号
万物皆对象
Original
788 people have browsed it

实例

<!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

Correction status:qualified

Teacher's comments:下次记得给代码加上线上运行的功能
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post