gpt4 book ai didi

jquery - 如何使用jquery将图像添加到div的顶部

转载 作者:行者123 更新时间:2023-11-28 04:40:50 25 4
gpt4 key购买 nike

我有一个空的 div,它是可拖动的,我需要在其左上角添加一个图像,它应该能够与 div 一起移动。

那我该怎么做呢?

<div class="example">
<div>

这是脚本:

 <script type="text/javascript">
$(function () {

$('.example').draggable

});
</script>

最佳答案

    .example {
position: relative;
}
.example .imghandle {
position: absolute;
height: 30px;
width: 30px;
top: -30px;
left: -30px;
}

<div class="example">
<div class="imghandle"></div>
<div>

将图像作为 div 的背景,或者只放一个 <img>在那里标记并添加类

here it is with :before

关于jquery - 如何使用jquery将图像添加到div的顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7908659/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com