表格中超级简单的 CSS 工具提示,为什么它不显示,我可以让它工作吗?

2024-04-26

我一直在尝试为我的客户在此页面上实现许多不同的工具提示,他坚持认为,当您将鼠标悬停在订单页面中的产品名称上时,我们会显示产品图片。我决定使用超级简单的 CSS 工具提示,它非常容易实现并且完全符合我们的要求。它适用于动态页面,而我尝试过的其他页面则不然。

我在这里举了一个例子:表格示例中的 CSS 工具提示 http://jsfiddle.net/WNzhJ/.<-- 更新以删除错误.

HTML:

<table class="mytable" id="cart">

  <tr id="titles">
    <th id="varekodetext">Varekode</th>
    <th id="produkttext">Produkt</th>
    <th id="pristext">Pris</th>
    <th id="emptee">&nbsp;</th>
    <th id="antalltext">Antall</th>
    <th id="pristotaltext">Pris Total</th>
    <th id="sletttext">Slett</th>
  </tr>
  <tbody>
    <tr class="even first" id="topborder" height="40px">
      <td class="cart2Varekode"> <span>39261-02 </span>
      </td>
      <td class="cart2Produkt"> <a href="/Plantronics-CS361N.11" target="_blank" class="tooltip" title="Plantronics CS361N"> 
                Plantronics CS361N
                <span> 
                    <img src="http://www.euroworker.no/public/upload/productimage/220-353-2.jpg" alt="Plantronics CS361N" /> 

                </span> 
                </a>
        <p>
        </p>
      </td>
      <td class="cart2Price">
        <span class="actualPrice">2390.-</span>
      </td>
      <td class="cart2Salg">
        <span class="orderlistPrice"></span>
      </td>
      <td class="antallbox">
        <span class="cartQuant"><input name="item_1363" class="DG-spinner" id="text" type="text" value="1"/> <span class="cartUpdate"><button type="submit" class="submit" id="rfrsh_btn" name="saveFields" title="Oppdater" value="">&nbsp;</button></span>
        </span>
      </td>
      <td class="cart2Total">
        <span class="basePrice">2390.-</span><span class="actualPrice">2390.-</span>
      </td>
      <td class="delete">
        <a class="slett" href="../..//order/delete/1363?return=" title="Slett">Remove</a>
      </td>
    </tr>
    <tr class="odd last" id="topborder" height="40px">
      <td class="cart2Varekode"> <span>7050-20</span>
      </td>
      <td class="cart2Produkt"> <a href="/Target-7050CC-Duo-UNC.7" target="_blank" class="tooltip" title="Target 7050CC Duo UNC">Target 7050CC Duo UNC<span>
      <img src="/upload/productimage/7-250-2.jpg?1251022192" alt="Target 7050CC Duo UNC" />               
                </span> 
                </a>

        <p>
          <div class="productOptions" style="color:#b2b2b2;">

            <div class="nonEditableOption">
              Skal tilkobles: Alcatel IP Touch
            </div>

            <div class="productOptionsMenu">
              <a style="color:#6c8aa2;" href="/order/options/1377" ajax="/order/optionForm/1377">Endre valg</a>
            </div>
          </div>

        </p>

      </td>
      <td class="cart2Price"><span class="actualPrice">899.-</span>
      </td>
      <td class="cart2Salg">
        <span class="salg" title="Rabatt">&nbsp;</span>

        <span class="orderlistPrice" title="Opprinnelige prisen"> 
                    (1599.-)
                </span>
      </td>
      <td class="antallbox">
        <span class="cartQuant"><input name="item_1377" class="DG-spinner" id="text" type="text" value="1"/> 

                    <span class="cartUpdate"><button type="submit" class="submit" id="rfrsh_btn" name="saveFields" title="Oppdater" value="">&nbsp;</button></span>
        </span>
      </td>


      <td class="cart2Total">

        <span class="basePrice">899.-</span><span class="actualPrice">899.-</span>

      </td>
      <td class="delete">

        <a class="slett" href="../..//order/delete/1377?return=" title="Slett">Remove</a>

      </td>
    </tr>
    <tr>
      <td colspan="6" class="cols-six"></td>
    </tr>
    <tr id="topborder-tr">
      <td class="subTotalCaption2">&nbsp;</td>
      <td colspan="4" class="subTotalCaption2">Mva (25%):</td>
      <td class="amount taxAmount2">822.-</td>
      <td>&nbsp;</td>



    </tr>
    <tr>
      <td class="subTotalCaption2">&nbsp;</td>
      <td colspan="4" class="subTotalCaption2">Totalt:</td>
      <td class="subTotal2">4111.-</td>
      <td>&nbsp;</td>

    </tr>
    <tr>
      <td colspan="5"></td>
      <td class="cartQuant"></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td colspan="7">
        <a href="/" class="continueShopping"><span>&nbsp;</span></a>
        <div class="checkoutButtons">
          <a href="/checkout" class="proceedToCheckout" onclick="return Order.submitCartForm(this);"><span>&nbsp;</span></a>

        </div>
      </td>
    </tr>
    <script type="text/javascript">
      new Order.OptionLoader($('cart'));

    </script>

  </tbody>

</table>

CSS:

.cart2Produkt a:hover {
  background: #ffffff;
  text-decoration: none;
  z-index: 999;
}

/*BG color is a must for IE6*/

.tooltip {
  text-align: left;
}

.cart2Produkt a.tooltip span {
  z-index: 999;
  display: block;
  position: absolute;
  left: -999px;
  opacity: 0;
  padding: 2px 3px;
  margin-left: 8px;
  width: 130px;
  -webkit-transition: opacity;
  -webkit-transition-timing-function: ease-in;
  -webkit-transition-duration: 500ms;
}

.cart2Produkt a.tooltip:hover span {
  z-index: 999;
  display: block;
  position: absolute;
  right: 50%;
  opacity: 1;
  background: #ffffff;
  border: 1px solid #cccccc;
  color: #6c6c6c;
  top: -35px;
  left: -15px;
  z-index: 10;
  border-radius: 5px;
  -moz-border-radius: 5px;
  -webkit-border-radius: 5px;
  text-align: center;
  vertical-align: middle;
  padding: 1px;
  -webkit-transition: opacity;
  -webkit-transition-timing-function: ease-out;
  -webkit-transition-duration: 500ms;
}


/**************IGNORE BELOW*************/

#topborder {
  /*border-top: 1px #ccc solid;*/
  padding-bottom: 10px;
}

#topborder-tr {
  border-top: 1px #ccc solid;
}

.mytable {
  width: 100%;
  margin-bottom: 20px;
}

.mytable,
.mytable th,
.mytable tr,
.mytable td {
  border: 0;
  letter-spacing: 1px;
}

.mytableborders,
.mytableborders th,
.mytableborders tr,
.mytableborders td {
  border: 1px #ccc solid;
  /*width:670px;*/
}

.mytable td,
.mytable td span {
  padding-bottom: 0;
  padding-top: 5px;
  /*border-top: 1px #ccc solid;*/
  vertical-align: middle;
  font-size: 12px;
}

.mytable th {
  vertical-align: bottom;
  height: 30px;
  padding-bottom: 5px;
}

#titles {
  margin: 0px auto 0px auto;
  width: 100%;
  padding-bottom: 50px;
  z-index: 1;
  border: 1px #ccc solid;
  border-left: none;
  border-right: none;
}

.cart2Produkt a {
  color: #0a5692;
  text-decoration: none;
  line-height: 15px;
  clear: both;
  z-index: 999;
}

productOptionsMenu {
  clear: both;
}

#pristotaltext p,
#varekodetext p,
#sletttext p,
#pristext p,
#antalltext p,
#produkttext p {
  font: 12px/11px "Helvetica";
  margin: 0px;
  color: #828273;
  text-align: left;
}

#thinline,
#thinlinecopy {
  background: url(../../upload/thinline.png) no-repeat;
  visibility: visible;
  position: absolute;
  left: 0px;
  z-index: 4;
  width: 747px;
  height: 1px;
}

#thinlinefakt {
  background: url(../../upload/thinline.png) no-repeat;
  visibility: visible;
  position: absolute;
  top: 100px;
  left: 0px;
  z-index: 4;
  width: 747px;
  height: 1px;
}

#thinlinefakt2 {
  background: url(../../upload/thinline.png) no-repeat;
  background-position: bottom;
  visibility: visible;
  position: absolute;
  top: 205px;
  left: 0px;
  z-index: 4;
  width: 747px;
  height: 28px;
  margin: 5px;
  margin-left: 10px;
  margin-top: 0px;
  padding: 5px;
  color: #000000;
  font-size: 22px;
  font-family: "Helvetica";
}

.Fadresse {
  display: block;
  margin: 5px;
  padding: 0;
  color: #000000;
  font-size: 22px;
  font-family: "Helvetica";
}

#thinlinecopylever {
  background: url(../../upload/thinline.png) no-repeat;
  background-repeat: repeat-x;
  position: relative;
  left: 0px;
  top: -3px;
  width: 100%;
  height: 1px;
  padding: 0px;
}

#varekodetext {
  width: 65px;
  padding-left: 5px;
  text-align: center;
}

#produkttext {
  width: 150px;
}


/*#sgproductview  {

margin: 0px auto 0px auto;
width: 595px;
height:1%;
z-index:1;
}*/

#thinlinecopy {
  top: 1px;
}

#antalltext {
  width: 25px;
  text-align: center;
}

#pristotaltext {
  width: 10%;
  text-align: right;
}

#sletttext {
  width: 10%;
  text-align: center;
}

#thinline {
  top: 19px;
  position: absolute;
}

#pristext {
  width: 24px;
  text-align: center;
}

#emptee {
  background-color: none;
  width: 40px;
}


/*****************************************CONTENT*/

.cart2Produkt p,
.cart2Varekode p,
.cart2Salg p {
  font: 13px/11px "Helvetica";
  margin: 0px;
  letter-spacing: 1px;
  text-align: left;
}

.cart2Produkt p a {
  color: #000000;
}

.cart2Total p {
  font: 13px/11px "Helvetica";
  margin: 0px;
  letter-spacing: 1px;
  text-align: left;
  color: #000000;
}

.cart2Varekode {
  visibility: visible;
  z-index: 2;
  text-align: center;
  vertical-align: top;
  padding-top: 3px;
  font-weight: bold;
}

.cart2Produkt {
  visibility: visible;
  text-decoration: none;
  text-align: left;
  position: relative;
  width: 28%;
  font-weight: bold;
  padding-bottom: 2px;
}

.cart2Produkt a {
  white-space: nowrap;
}

.cart2Price {
  visibility: visible;
  z-index: 2;
  text-align: right;
  width: 6%;
  position: relative;
  font-weight: bold;
}

.cart2Price p {
  font: 13px/11px "Helvetica";
  margin: 0px;
  letter-spacing: 1px;
  text-align: right;
  width: 80%;
}

.cart2Total p {
  font-weight: bold;
  text-align: right;
}

.cart2Salg p {
  color: #B2B2B2;
  width: 20%;
}

.cart2Total {
  visibility: visible;
  z-index: 2;
  text-align: right;
  font-weight: bold;
}

.antallbox {
  white-space: nowrap;
  text-align: center;
}

.antallbox input {
  text-align: right;
  outline: none;
  width: 30px;
}

.antallbox input:focus {
  text-align: right;
  outline: none;
  border: 1px #000 solid;
  background-color: #F0F7FD;
}

.cartQuant {
  width: 30px;
  /*    white-space: nowrap;*/
  text-align: left;
  margin-top: 5px;
}

.cart2Salg {
  visibility: visible;
  z-index: 2;
  padding: 0;
  margin: 0;
}

.orderlistPrice {
  text-decoration: line-through;
  font-weight: bold;
  color: #b2b2b2;
  font-size: 12px;
}

.salg {
  background: url(../../upload/salg.png) no-repeat;
  visibility: visible;
  z-index: 2;
  width: 28px;
  height: 24px;
  display: inline-block;
  position: relative;
}

.delete {
  visibility: visible;
  z-index: 2;
  height: 21px;
  background: none;
  text-align: center;
}

.slett {
  width: 24px;
  height: 19px;
  background-image: url(../../upload/delete_box_sprite.png);
  background-position: 0 0;
  text-decoration: none;
  display: inline-block;
}

.slett:hover {
  width: 24px;
  height: 19px;
  background-image: url(../../upload/delete_box_sprite.png);
  background-position: -24px 0;
  text-decoration: none;
  display: inline-block;
}

.productOptions {
  background-color: #fff;
  postion: absolute;
  visibility: visible;
  display: block;
  top: 3px;
  padding-left: 5px;
  padding-bottom: 10px;
}

.nonEditableOption {
  background-color: #fff;
  float: left;
  postion: absolute;
  margin-right: 10px;
  visibility: visible;
  display: block;
}

该页面过去使用 div 显示,后来我将其更改为表格,因为它是表格数据并且更易于使用。使用 div 时效果很好,现在它在表格中,悬停时不会显示跨度。

我的问题是:

  1. 为什么它不起作用?

  2. 我怎样才能让它发挥作用?

  3. 如果没有的话,有没有人 知道另一个超级容易实现的 可以正常工作的工具提示 动态页面?

这是 DIV 工具提示供参考:DIV显示工具提示 http://jsfiddle.net/waFC8/.

HTML:

<div id="JSwrap">
    <div id="cart2Produkt">
        <p><a href="/Target-7050-Softphone-USB-Duo.220" target="_blank" class="tooltip" title="Target 7050 Softphone USB Duo ">Target 7050 Softphone USB Duo
    <span><img src="http://www.euroworker.no/public/upload/productimage/220-353-2.jpg?1251413379" alt="Target 7050 Softphone USB Duo " />
<br /> 
  </span> 
</a>
        </p>
    </div>
</div>

CSS:

#JSwrap {
  /*for jsfiddle only*/
  position: absolute;
  left: 100px;
  top: 50px;
}

#cart2Produkt {
  border: 1px solid #ccc;
  width: 500px;
  text-align: left;
  padding: 10px;
}

#cart2Produkt a.tooltip span {
  z-index: 999;
  display: block;
  position: absolute;
  left: -999px;
  opacity: 0;
  padding: 2px 3px;
  margin-left: 8px;
  width: 130px;
  -webkit-transition: opacity;
  -webkit-transition-timing-function: ease-in;
  -webkit-transition-duration: 500ms;
}

#cart2Produkt a.tooltip:hover span {
  z-index: 999;
  display: block;
  position: absolute;
  right: 50%;
  opacity: 1;
  background: #ffffff;
  border: 1px solid #cccccc;
  color: #6c6c6c;
  top: -35px;
  left: -15px;
  z-index: 10;
  border-radius: 5px;
  -moz-border-radius: 5px;
  -webkit-border-radius: 5px;
  text-align: center;
  vertical-align: middle;
  padding: 1px;
  -webkit-transition: opacity;
  -webkit-transition-timing-function: ease-out;
  -webkit-transition-duration: 500ms;
}

#cart2Produkt img {
  z-index: 999;
}

Edit: 刚刚注意到它在 IE8 中可以工作一半。

Update:现在它可以在所有浏览器中运行,感谢 Daniel 指出我的 CSS 错误,但是有没有办法让它显示在表格单元格之外?


寻找更具可读性的工作解决方案here http://jsfiddle.net/n9GdP/1/:

.cart { width: 100%; }

.hasTooltip span {
    display: none;
    color: #000;
    text-decoration: none;
    padding: 3px;
}

.hasTooltip:hover span {
    display: block;
    position: absolute;
    background-color: #FFF;
    border: 1px solid #CCC;
    margin: 2px 10px;
}
<table class="cart"> 
    <tr> 
        <th id="pos">Pos</th> 
        <th id="name">Product</th> 
        <th id="price">Price</th> 
    </tr> 
    <tbody> 
        <tr>
            <td>1</td>
            <td>
                <a href="productdetails.htm" class="hasTooltip">Flatscreen 
                    <span>New visual experience!</span>
                </a>
            </td>
            <td>19.99</td>
        </tr>
        <tr>
            <td>2</td>
            <td>
                <a href="productdetails.htm" class="hasTooltip">Headset 
                    <span>Inject music directly into your ears!</span>
                </a>
            </td>
            <td>19.99</td>
        </tr>
    </tbody> 
</table>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

表格中超级简单的 CSS 工具提示,为什么它不显示,我可以让它工作吗? 的相关文章

  • 通过鼠标和触摸在画布上绘图

    我想在画布上绘图 使用鼠标效果很好 但我必须如何修改代码才能使其在 iPad 或 Nexus 上运行 link http jsfiddle net FgNQk 6 var canvas document getElementById can
  • 如何在列表中使用 CSS 计数器而不重置计数器?

    我想要有多个 ol 列表 其中计数器值not在列表之间重置 另一种说法是 我希望第二个列表中第一个 li 的计数器比前一个列表最后一个元素的计数器值高一个 有什么 CSS 魔法可以做到这一点吗 While 苏的回答 https stacko
  • CSS 六角形图案

    我找到了一个关于如何使用 CSS 创建六边形图案的很棒的 stackoverflow 答案 使用 CSS3 生成重复的六边形图案 https stackoverflow com questions 10062887 generate rep
  • 自定义字体,eot,不起作用

    我无法让我的自定义字体在 IE7 和 IE8 中工作 http i creative dk iJob http i creative dk iJob 它在 IE9 Firefox 和 Chrome 中运行良好 对于 Firefox 和 Ch
  • 如何在 Ruby 中获取网页的 HTML 源代码 [重复]

    这个问题在这里已经有答案了 在 Firefox 或 Safari 等浏览器中 打开网站后 我可以右键单击该页面 然后选择以下内容 查看页面源代码 或 查看源代码 这显示了该页面的 HTML 源代码 在 Ruby 中 是否有一个函数 也许是一
  • 使用 MathJax 排版/渲染动态内容

    我使用 MathJax 来显示数学方程 它在静态编写的数学中运行良好 但不适用于动态添加的数学 这是我的代码 Static div span x b pm sqrt b 2 4ac over 2a span div Dynamic div
  • 了解 Beautiful Soup 中的 Find() 函数

    我知道我想做的事情很简单 但这让我感到悲伤 我想使用 BeautifulSoup 从 HTML 中提取数据 为此 我需要正确使用 find 功能 这是我正在使用的 HTML div class audit div class profile
  • 除了text/css之外还有其他样式类型吗? [复制]

    这个问题在这里已经有答案了 可能的重复 style type text css 还有什么 https stackoverflow com questions 6077905 style type text css what else is
  • XSL:让原始 HTML 通过

    我正在进行 XSL 转换 我正在转换的 XML 有一个包含 html 的节点
  • 如何偏移网格项目,同时移动其兄弟项目? [复制]

    这个问题在这里已经有答案了 我正在使用 CSS 网格 我想偏移一个元素 以便它在网格列上水平移动 我还希望这个元素保留其当前宽度 并应用偏移值此外到元素的宽度 Example container display grid grid temp
  • 表单方法=“获取”漂亮的URL

    所以我使用这个 HTML 表单作为一个简单的搜索字段
  • “块样式”单选按钮适用于除 iPad 之外的所有设备

    我有一组单选按钮 并对它们进行了样式设置 以便它们显示 块 以便它们看起来像按钮 还隐藏了单选按钮本身 这在台式机和 Android 平板电脑上的 Chrome 和 Firefox 中效果很好 但在 iPad 上不起作用 在这里查看 htt
  • CSS相对div的宽度自动按绝对div扩展

    是否可以让父级 位置 相对 自动通过其绝对子级扩展其宽度 这是我的 jsfiddle 链接 http jsfiddle net YD2Xu http jsfiddle net YD2Xu 理想的是 container 和 full widt
  • IE8 的透明 png 渲染在我的网站上很 FUBARed

    我刚刚下载了 IE8 完整版 这样我就可以测试我刚刚创建的网站 示例已删除 关注左侧边栏背景图像 它应该是一个重复的 1x1 半透明 png 图像 IE8将其渲染为渐变 当您尝试滚动窗口或将鼠标悬停在侧边栏上时 它会变得更加不稳定 我已经在
  • 为什么 justify-content 不以我的 div 为中心?

    我试图将两个 div 水平居中放在爸爸 div 内 爸爸 div 设置为flex direction column因为我希望子 div 一个在另一个之下 但位于页面的中心 justify content center 应该做但不起作用 我终
  • CSS:它渲染“ul > li”比“ul li”更快吗?

    正如我从少数人那里听说的那样 使用 gt 而不是 使渲染速度更快 slide hover gt div gt span border color c8c8c8 OR slide hover div span border color c8c
  • 使用 PHP 的 HTML 中的选项字段

    我想根据从下拉列表中选择的区域名称搜索员工列表 我可以将数据库中的区域名称检索到 PHP HTML 的下拉列表中 但现在我很困惑如何将下拉列表中的选定选项传递给 PHP 中的 SQL 查询 我还想要索引号 选定的选项 我的代码如下
  • 如何防止图像被裁剪

    我正在尝试创建一个包含很多图层的动画图片 为了在不同的屏幕上获得正确比例的图像 我使用covercss 属性值 我已经尝试过object fit对于图像和background size用于背景图像 这就是为什么我的宽屏幕图像被浏览器裁剪的原
  • 将文本字段输入限制为仅数字

    我搜索过谷歌 但我能找到的所有解决方案都非常复杂和冗长 我需要的是将我正在进行的调查中的文本字段的输入限制为仅数字 最快 最干净的方法是什么 我使用的是严格的 HTML 4 01 和 ECMAScript 提前致谢 最快
  • Three.js - 将 WebGL 和 CSS3D 与 iFrame 混合

    我准备了一个混合的工作页面WebGL and CSS3D 在SO的一点帮助下here https stackoverflow com questions 24681170 three js properly blending css3d a

随机推荐