【问题标题】:Text hover box becomes transparent文本悬停框变为透明
【发布时间】:2016-10-26 07:39:37
【问题描述】:

我一直在使用code found on this site 创建一系列文本悬停框,在我将它们用于表格中的文本之前,它们一直运行良好。似乎当悬停框在区域上弹出时,另一个框会弹出(虽然现在不存在),背景变得透明,使得文本悬停框很难阅读。

如果您查看此代码,结果中上方的笑脸有一个悬停框,您可以通过该悬停框查看其他屏幕上的文本。这是我的问题。我根据其他一些在线搜索尝试了 z-index 和不透明度设置,但到目前为止没有任何效果。

<style>
    .m span{display: none;list-style: none} .m {z-index:24;position:relative;display:inline-block}
    .m:hover span{z-index:999;display:block;position:absolute;top:19px;left:1em;border:1px solid #0195c8;background-color:#0195c8;color:#ffffff;min-width:300px}
</style>

<div class="m" style="font-family: &#39;trebuchet ms&#39;, helvetica;"> 
    <img src=http://2.bp.blogspot.com/-QEUhPNc1xag/UHnAq0rQQNI/AAAAAAAAAdI/JgtSqZHDIBY/s1600/smiley%2Bface%2Bwinking.jpg style="margin: 0px;          
         width: 40px;"/>
    <span><strong><u>second hover box</u></strong>
</div>

<style>
    .m span{display: none;list-style: none} .m {z-index:5000;position:absolute;display:inline-block}
    .m:hover span{z-index:5001;display:block;position:relative;top:19px;left:1em;border:1px solid #0195c8;background-color:#0195c8;color:#999999;min-width:300px;}
</style>

<div class="m" style="text-align: left;">ON SCREEN TEXT<br/><br/> and some more
    <span> first hover<br/><br/>more hover box</span>
</div>
<br/>
<style>
    .m span{display: none;list-style: none} .m {z-index:24;position:relative;display:inline-block}
    .m:hover span{z-index:999;display:block;position:absolute;top:19px;left:1em;border:1px solid #0195c8;background-color:#0195c8;color:#ffffff;min-width:300px}
</style>
<div class="m" style="font-family: &#39;trebuchet ms&#39;, helvetica;"> 
    <img src=http://2.bp.blogspot.com/-QEUhPNc1xag/UHnAq0rQQNI/AAAAAAAAAdI/JgtSqZHDIBY/s1600/smiley%2Bface%2Bwinking.jpg style="margin: 0px;          
         width: 40px;"/>
    <span><strong><u>second hover box</u></strong>
</div>

【问题讨论】:

    标签: html css hover


    【解决方案1】:

    你可以这样使用。它会帮助你

    <style>
    .m span{display: none;list-style: none} .m {z-index:24;position:relative;display:inline-block}
    .m:hover span{z-index:999;display:block;position:absolute;top:19px;left:1em;border:1px solid #0195c8;background-color:#0195c8;color:#000000;min-width:300px;opacity: 0.4; }
    </style>
                <div class="m" style="font-family: &#39;trebuchet ms&#39;, helvetica;"> 
                   <img src=http://2.bp.blogspot.com/-QEUhPNc1xag/UHnAq0rQQNI/AAAAAAAAAdI/JgtSqZHDIBY/s1600/smiley%2Bface%2Bwinking.jpg style="margin: 0px;          
                    width: 40px;"/>
                            <span><strong><u>second hover box</u></strong>
                </div>
    <style>
    .m span{display: none;list-style: none} .m {z-index:5000;position:absolute;display:inline-block}
    .m:hover span{z-index:5001;display:block;position:relative;top:19px;left:1em;border:1px solid #0195c8;background-color:#0195c8;color:#999999;min-width:300px;}
    </style>
             <div class="m" style="text-align: left;">ON SCREEN TEXT<br/><br/> and some more
                    <span> first hover<br/><br/>more hover box</span></div>
    <br/>
    <style>
    .m span{display: none;list-style: none} .m {z-index:24;position:relative;display:inline-block}
    .m:hover span{z-index:999;display:block;position:absolute;top:19px;left:1em;border:1px solid #0195c8;background-color:#0195c8;color:#ffffff;min-width:300px}
    </style>
                <div class="m" style="font-family: &#39;trebuchet ms&#39;, helvetica;"> 
                   <img src=http://2.bp.blogspot.com/-QEUhPNc1xag/UHnAq0rQQNI/AAAAAAAAAdI/JgtSqZHDIBY/s1600/smiley%2Bface%2Bwinking.jpg style="margin: 0px;          
                    width: 40px;"/>
                            <span><strong><u>second hover box</u></strong>
                </div>

    如需更多帮助,请使用此link

    【讨论】:

      【解决方案2】:

      你的代码太糟糕了。哈哈

      您只需要在正确的位置添加 z-index。这在你的 div 中。

      你的代码应该是这样的:

       <style>
          .m span{display: none;list-style: none} .m {z-index:24;position:relative;display:inline-block}
          .m:hover span{z-index:999;display:block;position:absolute;top:19px;left:1em;border:1px solid #0195c8;background-color:#0195c8;color:#ffffff;min-width:300px}
          </style>
          <div class="m" style="font-family: &#39;trebuchet ms&#39;, helvetica;z-index:25;"> 
              <img src=http://2.bp.blogspot.com/-QEUhPNc1xag/UHnAq0rQQNI/AAAAAAAAAdI/JgtSqZHDIBY/s1600/smiley%2Bface%2Bwinking.jpg style="margin: 0px;width: 40px;"/>
              <span>
                  <strong>
                      <u>second hover box</u>
                  </strong>
              </span>
          </div>
      
          <div class="m" style="text-align: left;">
              ON SCREEN TEXT<br/><br/>and some more
              <span> first hover<br/><br/>more hover box</span>
          </div>
          <br/>
      
      
          <div class="m" style="font-family: &#39;trebuchet ms&#39;, helvetica;"> 
              <img src=http://2.bp.blogspot.com/-QEUhPNc1xag/UHnAq0rQQNI/AAAAAAAAAdI/JgtSqZHDIBY/s1600/smiley%2Bface%2Bwinking.jpg style="margin: 0px;width: 40px;"/>
              <span>
                  <strong>
                      <u>second hover box</u>
                  </strong>
              </span>
      </div>
      

      【讨论】:

      • 谢谢丹尼。我知道这很糟糕,我正处于实时紧缩状态,并且由于无法发送真实代码而不得不提出一个示例。谢谢你的回答,我有一个跟进:在我的真实代码中,我有一堆堆叠在一起的代码。作为一项规则,准时的一个是否需要比下一个更高的数字?
      • 我还不知道,因为我希望你能对我的后续问题发表评论
      • 我的后续问题有意义吗?我一直在玩 z-index 数字,它似乎还在做。
      • 您可以根据需要使用 z-index。如果你没有显示你的代码和你想要什么,我不能再告诉你了。
      猜你喜欢
      • 2014-01-28
      • 2020-11-17
      • 2012-07-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多