zoukankan      html  css  js  c++  java
  • 相对定位以及父子节点之间的关系

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <style type="text/css">
            #myul li
            {
             float:left;
             list-style-type:none;
             }
            #myul li img
            {
             position:relative;
             top:150px;
             150px;
             height:150px;
             }
        </style>

        <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
        <script type="text/javascript">
            $(function () {
                $("#myul li img").click(function () {
                    //因为在样式表中,设置了这们的定位方式为relative所以,top=0;代表相对于它们原来的位置的
                    //偏移量为0;
                    $(this).css("top", "0");
                    //找到这张图片的父亲的兄弟的儿子
                    $(this).parent().siblings().children().css("top","150px");
                });
            })
        </script>
       
    </head>
    <body>
        <ul id="myul">
            <li>
                <img src="1.jpg" />
            </li>
            <li>
                <img src="2.jpg" />
            </li>
            <li>
                <img src="3.jpg" />
            </li>
            <li>
                <img src="4.jpg" />
            </li>
        </ul>
    </body>
    </html>

    ps:重点是父子节点间的关系问题

  • 相关阅读:
    找到排序矩阵中从小到大第K个数字
    使用VSCODE开发UE4
    UE4添加模块
    游戏串流
    DIY Arduino 方向盘
    免费/开源软件推荐
    把引擎插件变成工程插件
    MergeActors技巧
    烘焙卡在99%
    UMG里没有"Prefab"怎么办?
  • 原文地址:https://www.cnblogs.com/La5DotNet/p/2461079.html
Copyright © 2011-2022 走看看