Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/405.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在鼠标悬停时使图标显示在一行中_Javascript_Jquery_Css_Bootstrap 4 - Fatal编程技术网

Javascript 如何在鼠标悬停时使图标显示在一行中

Javascript 如何在鼠标悬停时使图标显示在一行中,javascript,jquery,css,bootstrap-4,Javascript,Jquery,Css,Bootstrap 4,我使用的是羽毛图标,当鼠标悬停在项目名称旁边时,我希望羽毛垃圾出现在项目名称旁边 我看到有人在书架上问这个问题,但没有找到答案 我的代码如下: <div class="container-fluid"> <div class="table-responsive"> <table class="table table-striped table-sm table-hover"> <thead> <tr&g

我使用的是羽毛图标,当鼠标悬停在项目名称旁边时,我希望羽毛垃圾出现在项目名称旁边

我看到有人在书架上问这个问题,但没有找到答案

我的代码如下:

<div class="container-fluid">
 <div class="table-responsive">
    <table class="table table-striped table-sm table-hover">
      <thead>
        <tr>
          <th class=" text-center">Item#</th>
          <th class=" text-center">Item Name</th>
          <th class=" text-center">Qty</th>

      </thead>
      <tbody>
        <tr>
          <td>1,001</td>
          <td>Apple</td>
          <td class=" text-right">5</td>

        </tr>
        <tr>
          <td>1,002</td>
          <td>Kidney Beans</td>
          <td class=" text-right">3</td>

        </tr>

项目#
项目名称
数量
1,001
苹果
5.
1,002
芸豆
3.

  • 向图标元素添加一个类
  • 通过添加此属性将其隐藏
    style=“display:none;”
  • 将悬停效果添加到CSS文件:
    .youriconclass:hover{display:block;}

  • jQuery悬停方法可以帮助您完成任务。首先,您需要添加一些HTML修改,比如为图标创建一个容器。e、 g

          <td class="trigger-icon">
             Apple 
             <span class="icon-container"> </span>
          </td> 
    
    
    苹果
    
    现在来看js部分

        $(".trigger-icon").hover(function(){
         $(".icon-container").append('<i data-feather="trash"></i>');
        }, function(){
         $(".icon-container").empty();
        });
    
    $(“.trigger icon”).hover(函数(){
    $(“.icon容器”).append(“”);
    },函数(){
    $(“.icon容器”).empty();
    });
    
    为了让羽毛图标正常工作

       $(".trigger-icon").hover(function(){
         $(".icon-container").append('<i data-feather="trash"></i>');
         feather.replace();
        }, function(){
         $(".icon-container").empty();
        });
    
    $(“.trigger icon”).hover(函数(){
    $(“.icon容器”).append(“”);
    feather.replace();
    },函数(){
    $(“.icon容器”).empty();
    });
    
    原则:

    tr .fa {                            /* row not hovered */
      opacity: 0;
      transition: opacity .2s ease-out; /* adding transition, improved UI */
      cursor: pointer;                  /* change cursor when hovering icon */
      transition-delay: .5s;            /* delay the icon fading out */
    }
    
    tr:hover .fa {                      /* row hovered */
      opacity: 1;
      transition-delay: 0s;             /* cancel delay when entering */
    }
    
    以最简单的形式:

    tr .fa {
      opacity: 0;
    }
    tr:hover .fa {
      opacity: 1;
    }
    
    工作示例:

    tr.fa{
    保证金权利:.5rem;
    不透明度:0;
    过渡:不透明度。2s缓解;
    光标:指针;
    转换延迟:.5s;
    }
    tr:hover.fa{
    不透明度:1;
    转换延迟:0s;
    }
    
    项目#
    项目名称
    数量
    1,001
    苹果
    5.
    1,002
    芸豆
    3.
    
    使用我当前的代码尝试此操作,结果显示为空。。此外,我正在通过html链接我的css,如何编辑bootstrap.min.css文件?我想有人建议不要编辑这个,如果我把它放在本地的话?不要编辑你的bootstrap.css文件。如果要添加自定义CSS,请创建自己的style.CSS文件,并在“签出:快速问题”中链接到该文件。。js部分,我可以把它放在js部分之间html的底部吗?或者我必须做一些不同的事情吗?它应该在$(document).ready方法中。作为参考,看看这个Nafiz它不适合我。。我一直在尝试这两个示例//是否可以在codepen中共享js代码,以便查看结构?你能不能检查一下你是否可以用简单的文本,比如“Hello”而不是“Hello”?是的。。我该怎么做?陶。。这在你的例子中肯定是可行的。。那正是我想要的。。你能告诉我这个原则是否应该在我的css文件中发布吗?或者在我的html工作表中使用脚本open and close?@S,记住向上投票任何有用的答案,并将其中一个标记为已接受。这改进了索引,总体而言,有助于未来用户更快地找到正确答案。。再次感谢tao-stack是否提供一对一课程?比如说,如果我想时不时地直接挑选你的大脑?不是真的,但我只是做了。当我在信中被提及时,我会得到通知。最有可能的是,我仍然希望你问一个适当的问题,这样任何有同样问题的人都可以从答案中受益。