简体   繁体   English

如何使JQuery在文本右边(而不是下面)显示悬停图像?

[英]How to make JQuery display hover image to the right of text (instead of below)?

I am using JQuery code for a particular operation. 我正在对特定操作使用JQuery代码。 When you move your cursor over text my code displays an icon. 当您将光标移到文本上方时,我的代码显示一个图标。

I have a problem when I move cursor over the text, my image should appear to the right. 将光标移到文本上时出现问题,图像应显示在右侧。 Currently, it appears below the text. 当前,它显示在文本下方。

Best thing to do would be to set the background-image and padding of the text with the jquery: 最好的办法是使用jquery设置背景图像和文本的填充:

$(".pictureTrigger").hover(
  function () {
    $(this).attr('style', 'padding-left: 20px; background:url() top left no-repeat'); 
  }
);

check it out here , its a staring point for you, you'll need to do the mouseout if you want it to go too. 此处查看它, 对您来说是个凝视点,如果您也想将鼠标移开,则需要将其移出。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM