简体   繁体   English

旋转并按住Font Awesome图标的位置

[英]Rotate and Hold Postion of Font Awesome Icon

I want the exact function as shown here in the menu with the icon 我想确切的函数,如在这里与图标菜单

So far I have: 到目前为止,我有:

  1. The Navbar in place 导航栏到位
  2. The Fontawesome Icon (fa-angle-down) in place Fontawesome图标(向下倾斜)
  3. The Icon rotates but only when the mouse is over the icon, while i want it to be able to rotate when the mouse over is on the "li" of the menu item. 图标旋转,但仅当鼠标悬停在图标上方时,而我希望鼠标悬停在菜单项的“ li”上时能够旋转。 Also, when the mouse is taken to the dropdown list item, the rotate icon should remain as is. 另外,将鼠标移到下拉列表项时,旋转图标应保持不变。

Code so far: JSFiddle 到目前为止的代码: JSFiddle

$("li.dropdown > a > i").hover(
    function () {
        $(this).addClass("gxcpl-fa-rotate-45");
    },
    function () {
        $(this).removeClass("gxcpl-fa-rotate-45");
    }
);

You're only targeting the icon: 您只定位图标:

  $("li.dropdown > a > i").hover(

You need to target the <li> and then apply the class to its child <i> : 您需要定位<li> ,然后将该类应用于其子<i>

$("li.dropdown").hover(
  function () {
    $(this).find("i").addClass("gxcpl-fa-rotate-45");
  },
  function () {
    $(this).find("i").removeClass("gxcpl-fa-rotate-45");
  }
);

Check out the fiddle here 这里查看小提琴

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

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