【问题标题】:Wordpress tooltip getting blocked by browsersWordpress 工具提示被浏览器阻止
【发布时间】:2022-01-02 05:57:03
【问题描述】:

我正在尝试使用 WordPress 主题制作图形设计作品集。在其中,我使用 Shortcodes Ultimate 插件创建了一个工具提示。它用于在将鼠标悬停在图像上时显示一个人的名称。但不幸的是,只有在禁用浏览器跟踪保护设置时,它才在实时网站上可见。我应该怎么做才能让浏览器不阻止它?

以下是我用来创建工具提示的代码

[su_tooltip text="UI designer" font_size="12"]

<figure class="wp-block-image size-full is-resized img-filter parallax-element parallax-wrap">
    <a href="https://www.linkedin.com/in/ashish-yadav/" target="_blank" rel="noopener">
        <img src="https://vedsarkar.com/wp-content/uploads/2019/11/Ashish.png" alt="" class="wp-image-3438" width="55" height="55">
    </a>
</figure>

[/su_tooltip]

【问题讨论】:

    标签: html css wordpress shortcode


    【解决方案1】:

    如果插件中的脚本来自外部源而不是本地,则它可能会被阻止。如果它来自本地,则可能是该插件具有其他标志,例如将文件或文件夹命名为“营销”。

    应尽量减少使用 WP 插件。不需要插件,只用 HTML 和 CSS 就可以达到你想要的效果。

    这是一个粗略的想法。 (也在CodePen上)

    body {
      font-family: arial;
      padding-top: 20px
    }
    .thumbnail-container {
      display: flex;
      flex-direction: row;
      margin: 40px auto; 
      justify-content: center;
    }
    figure img {
      transition: transform 0.05s linear;
      transform: scale(1);
    }
    figure:hover img {
      transform: scale(1.5);
    }
    
    figure > a {
      position: relative; 
      display: block;
    }
    
    figure > a:before,
    figure > a:after {
       transition: transform, margin 0.05s linear;
      content: " ";
      position: absolute;
      display: block;
      background-color: #222;
      width: 20px;
      height: 20px;
      top: 0;
      left: 0;
      right: 0;
      margin: 0 auto;
      bottom: auto;
      z-index: 1;
      opacity: 0;
      pointer-events: none;
    }
    
    figure > a:before {
      content: attr(title);
      min-width: calc(100% + 40px);
      top: -60px;
      color: #fff;
      margin-left: -30px;
      padding: 8px 10px;
      border-radius: 10px;
      text-align: center;
      z-index: 2;
      white-space: nowrap;
    }
    
    figure > a:after {
      transform: rotate(45deg);
      top: -40px;
    }
    
    
    figure > a:hover:before,
    figure > a:hover:after {
      opacity: 1;
      margin-top: -5px
    }
    <div class="thumbnail-container">
      <figure class="wp-block-image size-full is-resized img-filter parallax-element parallax-wrap ">
        <a href="https://www.linkedin.com/in/ashish-yadav/" target="_blank" rel="noopener" title="Some Tooltip">
            <img src="https://vedsarkar.com/wp-content/uploads/2019/11/Ashish.png" alt="" class="wp-image-3438" width="55" height="55">
        </a>
    </figure>
    <figure class="wp-block-image size-full is-resized img-filter parallax-element parallax-wrap">
        <a href="https://www.linkedin.com/in/ashish-yadav/" title="Other tooltip" target="_blank" rel="noopener">
            <img src="https://vedsarkar.com/wp-content/uploads/2019/11/Ashish.png" alt="" class="wp-image-3438" width="55" height="55">
        </a>
    </figure>
    
    <figure class="wp-block-image size-full is-resized img-filter parallax-element parallax-wrap">
        <a href="https://www.linkedin.com/in/ashish-yadav/" target="_blank" rel="noopener" title="Last Tooltip">
            <img src="https://vedsarkar.com/wp-content/uploads/2019/11/Ashish.png" alt="" class="wp-image-3438" width="55" height="55">
        </a>
    </figure>
    
    
      
    </div>

    【讨论】:

    • 谢谢,JBS 它的作用就像一个魅力,但你能不能稍微编辑一下代码,使工具提示也能包含 19-20 个字符长的单词。
    • 很高兴听到 Ved。我更新了 CodePen 版本,使其可以有多行。 codepen.io/simmbiote/pen/LYjovzp
    • 嗨,我刚刚注意到一个奇怪的行为。提供的解决方案产生了两个工具提示,一个带有自定义 CSS,另一个带有默认 CSS。你能指定如何隐藏默认的吗?
    • 通过传递 id 而不是标题来修复它
    • 我不会使用 id 属性,因为将带有空格的字符串作为值在技术上是无效的。相反,添加自定义属性 data-tooltip=""。以 data- 为前缀的属性可以是任何你喜欢的。 Codepen 更新
    猜你喜欢
    • 1970-01-01
    • 2015-07-25
    • 1970-01-01
    • 2012-09-14
    • 2018-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多