如何在jQuery中的鼠标悬停时移动文本? [英] how to move text on mouse over in jquery?
本文介绍了如何在jQuery中的鼠标悬停时移动文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当鼠标悬停在上方时如何使链接向左移动?我希望在鼠标移出时将文本移回. jquery有可能吗?请帮忙.
How to make a link moving to left when mouse over? I want the text move back when mouse out. Is it possible with jquery? Please help.
谢谢
推荐答案
无论是否在jQuery中,您都将使用CSS,不确定为什么要使用jQuery作为开始,但是无论如何,这里有一个示例:>
You would use CSS regardless if it's in jQuery or not, not sure why you would use jQuery to begin with, but anyways, here is an example:
<a href="#">Move me Left</a>
<script type="text/javascript" language="javascript">
$("a").hover(function(){ $(this).css('margin-left','-50px') });
</script>
此处的margin-left
设置为-50px(减去后缀),但可以根据自己的喜好进行更改.
The margin-left
is set to -50px here (minus to go backwords), but can be changed according to your liking.
否则,在CSS中,您所需要做的就是:
Otherwise in CSS all you would need to do is:
a:hover { margin-left: -50px; }
看看CSS这么简单吗?
See how much easier that is in CSS?
这篇关于如何在jQuery中的鼠标悬停时移动文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文