首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jQuery左移

jQuery左移
EN

Stack Overflow用户
提问于 2012-05-17 20:16:51
回答 2查看 948关注 0票数 0

我试图给子菜单添加一个小的漂亮的效果,但是我不能使用marginLeft,因为它会把容器弄乱一点。所以我试着用left代替marginLeft,但是我不能让它工作...你知道为什么吗?

代码语言:javascript
复制
$('#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);
  });
});
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-05-17 20:20:05

CSS Left仅适用于positioned元素。

尝试向li添加position:relative;

例如:

代码语言:javascript
复制
#order_list li {
  position: relative;
}
票数 4
EN

Stack Overflow用户

发布于 2012-05-17 20:20:12

代码语言:javascript
复制
$('#order_list li').hover(function(){
  $(this).stop().animate({ "textIndent": "14px" }, 250, function() {
    $(this).animate({ "textIndent": "10px" }, 250);
  });
},function(){
  $(this).stop().animate({ "left": "4px" }, 250, function() {
    $(this).animate({ "textIndent": "0px" }, 250);
  });
});
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10635601

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档