css设置图片右上删除按钮

参考:https://blog.csdn.net/qq_33464127/article/details/77506461

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <script src="../js/jquery-1.9.1.min.js"></script>
        <style type="text/css">
        .imgDiv {
            display: inline-block;
            position: relative;
           
        }
 
            .imgDiv .delete {
                position: absolute;
                top: 0px;
                right: 0px;
                width: 10px;
                height: 10px;
                /*display: none; */
            }
    </style>
    </head>
    <body>
            <script type="text/javascript">
//      $(document).ready(init);
//      function init() {
//          $(".imgDiv").mouseenter(function () {
//              $(this).find(".delete").show();
// 
//          });
// 
// 
//          $(".imgDiv").mouseleave(function () {
//              $(this).find(".delete").hide();
//          });
// 
//      }
 
 
 
    </script>
    <div class="imgDiv">
        <img style="width: 50px;height: 50px;" src="../img/yuantiao.jpg" />
        <a href="#">
            <img src="../img/add.png" class="delete" />
        </a>
    </div>
        <div class="imgDiv">
        <img style="width: 50px;height: 50px;" src="../img/yuantiao.jpg" />
        <a href="#">
            <img src="../img/add.png" class="delete" />
        </a>
    </div>
    </body>
</html>

猜你喜欢

转载自blog.csdn.net/qq_37164847/article/details/86360651