jQuery 向左 move

标签 jquery html css move

我正在尝试向子菜单添加一个不错的小效果,但我不能使用 marginLeft,因为它会弄乱容器。所以我试图通过使用 left 而不是 marginLeft 来实现它,但我无法让它工作......任何想法为什么?

$('#order_list li').hover(function(){
  $(this).stop().animate({ "left": "14px" }, 250, function() {
    $(this).animate({ "left": "10px" }, 250);
  });
},function(){
  $(this).stop().animate({ "left": "4px" }, 250, function() {
    $(this).animate({ "left": "0px" }, 250);
  });
});

最佳答案

CSS Left仅适用于 positioned元素。

尝试将 position:relative; 添加到 li

例如

#order_list li {
  position: relative;
}

关于jQuery 向左 move ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10635601/

相关文章:

javascript - 如何从 contenteditable div 中提取文本(但不是 html 标签)

html - CSS break-word 在 Div 中不起作用

css - 在 HTML 表格标题单元格内垂直旋转文本

jquery - 如何在select中隐藏选中的元素?

javascript - jQuery Bootstrap 无法运行

javascript - 如何向此 "display none"jquery 脚本添加 "hcsticky"选项?

jquery - 将事件添加到创建的元素

javascript - 使用 javascript setTimeout() 设置 z-index

html - 内容随文本向下移动

javascript - 剪切路径圆弧形状