简体   繁体   English

反应工具提示,不显示在元素旁边

[英]React tooltip, dont show beside the element

It works fine with other buttons and elements I use on the page, but with the aside section that is on a fixed position.它适用于我在页面上使用的其他按钮和元素,但使用固定aside上的侧面部分。 The tooltip shows up on the bottom.工具提示显示在底部。 The next tooltip, for eksample for GitHub, shows up even further down.下一个工具提示,对于 GitHub 的 eksample,显示得更远。

I think it has something to do with the position in the CSS code, but I cannot figure it out.我认为它与 CSS 代码中的 position 有关,但我无法弄清楚。 Is there anyone that has had the same issue and can help?有没有人遇到过同样的问题并可以提供帮助?

CSS: CSS:

aside {
  background-color: #16123f;
  position: fixed;
  top: 40%;
  padding: 10px 20px;
  border-top-right-radius: 20px;
  border-bottom-right-radius: 20px;
  filter: drop-shadow(0px 3px 6px #00000045);
}

Code from the React component:来自 React 组件的代码:

<aside>
  <ul className="social">
    <li>
      <a data-tip data-for="ePost" href="mailto:stig.ark@gmail.com">
        <FontAwesomeIcon icon={faAt} className="fa-solid fa-at fa-lg" />
      </a>
      <ReactTooltip
        backgroundColor="#ed0b70"
        textColor="black"
        id="ePost"
        place="top"
        effect="solid"
      >
        Send meg en epost!
      </ReactTooltip>
    </li>

    // ...
  </ul>
</aside>

Here is how it looks, I want it right beside the aside .这是它的外观,我想要它在aside

I have managed to make it look like what you want with the following workaround (note overridePosition ):通过以下解决方法(注意overridePosition ),我设法使它看起来像您想要的:

<aside>
  <ul className="social">
    <li>
      <a data-tip data-for="ePost" href="mailto:stig.ark@gmail.com">
        <FontAwesomeIcon icon={faAt} className="fa-solid fa-at fa-lg" />
      </a>
      <ReactTooltip
        backgroundColor="#ed0b70"
        textColor="black"
        id="ePost"
        place="top"
        effect="solid"
        overridePosition = {() => {return { left: 30, top: -40 };}}
      >
        Send meg en epost!
      </ReactTooltip>
    </li>

    // ...
  </ul>
</aside>

This is what it looks like now:这就是它现在的样子:

在此处输入图像描述

As for a proper fix, I do think this is a bug in the library.至于适当的修复,我确实认为这是库中的一个错误。 It may be a good idea to open an issue in its GitHub reposotory but unfortunately it's not reasonable to expect a fix anytime soon, considering that the library has more than 250 open issues already and the last commit was more than 3 months ago.其 GitHub 存储库中打开一个问题可能是一个好主意,但不幸的是,考虑到该库已经有超过 250 个未解决的问题并且最后一次提交是在 3 个多月前,期望很快得到修复是不合理的。

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

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