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

标签 jquery css image html

我有一个空的 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/

相关文章:

python - 使用 python 的 bs4 的 HTML 选择器

html - 在图片上堆叠下拉菜单

javascript - Jquery-chosen 不适用于 ajax 附加选择

jquery - 删除 css 边界框轮廓

javascript - 滚动上的视差元素

html - Outlook 页脚 + HTML + CSS - 怎么做才能起作用?

Java : VolatileImage slower than BufferedImage

android - 在 Android Studio 中更改系统镜像的默认路径

javascript - 当内容改变高度时动态改变容器 div 的高度

javascript - iframe 对象的 jquery getscript