表格中超级简单的 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 工具提示,为什么它不显示,我可以让它工作吗? 的相关文章

  • 如何解决此错误:属性 rel 的原始源值错误

    我正在尝试使用 w3c 验证我的网站 但出现错误 Bad value original source for attribute rel on element link The string original source is not a
  • 使用其innerHTML查找元素

    请看一下这个 DOM 树 div div span Home1 span div span Home2 span span Home3 span div 现在假设我有一个场景 我以某种方式获得了第一个跨度的innerHTMLHome1 是否
  • 理解 z-index:该元素如何出现在其父级同级元素的前面?

    为什么当我删除时红色 div 位于绿色 div 前面z index from wrapperRed 感觉像z index是沿着链条向上继承的 如果我改变z index将绿色 div 更改为 6 即使删除第一句中描述的行后 它仍保留在红色 d
  • 单击导航项锚链接时如何关闭切换菜单

    请看我的FIDDLE http jsfiddle net ayhpp8ax 我有一个带有 响应式 导航菜单 带有指向页面上元素的锚链接 的 1 页网站 当浏览器视口小于特定宽度 在我的情况下为 767px 时 使用此 javascript
  • 使用 python 在一个 html 页面中显示分割数据框的 HTML 代码

    我是 html css 新手 所以对以 html 格式显示的数据有疑问 我有一个很长的列表 我想将其拆分并以 html 格式显示为两个单独的列 例如 而不是 Col1 Col2 1 a 2 a 3 a 4 a 5 b 6 b 7 b 8 b
  • jQuery mobile 中的文本区域高度和宽度?

    我修复了 jQuery mobile 中文本区域元素的高度 并且在纵向中得到了完美的高度和宽度 但在横向中宽度没有放大 谁能帮我 提前致谢 HTML
  • 无法使用 BeautifulSoup4 (Python 3) 抓取特定表

    我想从 Ligue 1 足球网站上抓取一张表格 具体来说 该表包含有关卡片和裁判的信息 http www ligue1 com LFPStats stats arbitre competition D1 http www ligue1 co
  • VBA 完成 Internet 表单

    我正在寻找将 Excel 中的值放入网页的代码 Sub FillInternetForm Dim IE As Object Set IE CreateObject InternetExplorer Application IE naviga
  • 使用本地存储在从另一个表保存的 HTML TABLE 中打印 JSON,以便我在另一个页面上打印我的表

    在我的作业中 我必须使用用户输入中的数据并将数据保存在本地存储中 我必须以水平表格式将这些数据从本地存储打印到其他页面 为此 我编写了用于用户输入并将数据保存在本地存储中的代码 div p p div
  • 在 ember-cli 中安装 Foundation 5

    我对 ember 相当陌生 对构建工具也很陌生 我目前正在使用通常的基础安装以及基础 cli 和指南针来编译我的 css 这有点痛苦 并且对于团队工作来说非常糟糕 我认为用 Bower 安装文件并使用会更好ember cli compass
  • Sass:@use 出错,未定义变量

    我正在使用 Sass 并且想要使用 use关键字而不是 import 因为 import有很多问题 另外只有dart sass支持这个功能 我将node sass改为dart sass 然而 问题出现了 我原来的代码 import carb
  • 浮动图像周围具有最小列宽的流动文本

    我想要一种方法来防止流动文本列变得太窄 例如 在一列 HTML 文本中 有一个图像浮动到左侧 正如预期的那样 文本沿着图像周围的列的右侧向下流动 但是 如果图像几乎与列一样宽 则文本最终会非常窄 在这种情况下 我希望文本简单地not流过图像
  • CSS 继承、别名和其他很酷的东西

    有一天 我随机浏览网页 发现了一些程序 可以让你编写 CSS 别名和其他很酷的东西 我现在不记得了 举个例子 我记得你可以这样做 myclass background color red greenfont 其中 greenfont 在其他
  • 滚动时的 CSS 背景模糊

    我有固定的背景图像 滚动时我希望图像变得模糊 我知道如何在 css 中进行模糊 但在特定的滚动位置进行 这是一个例子 https medium com good music f160ba9e6c52 https medium com goo
  • 如何使用javascript确保元素仅在圆上朝一个方向移动?

    好吧 我承认我对三角学真的很糟糕 出于上下文的考虑 我将添加我在这里提到的问题中的内容 参考问题 https stackoverflow com a 39429290 168492 https stackoverflow com a 394
  • 如何使用 Scrapy 从网站获取所有纯文本?

    我希望在 HTML 呈现后 可以从网站上看到所有文本 我正在使用 Scrapy 框架使用 Python 工作 和xpath body text 我能够获取它 但是带有 HTML 标签 而且我只想要文本 有什么解决办法吗 最简单的选择是ext
  • javascript 选择自定义光标 (svg)

    我正在动态地将光标更改为悬停时的本地 svg element on mouseover function this css cursor url svgs pointer svg 9 30 auto 工作正常 但我想选择该 svg 来操纵其
  • 如何使用角度材料在具有可扩展行的表格中创建嵌套垫表

    我有以下数据 id c9d5ab1a subdomain wing domain aircraft part id c9d5ab1a info mimetype application json info dependent parent
  • 使用 Javascript 设置 cookie [重复]

    这个问题在这里已经有答案了 我正在尝试构建我的第一个移动应用程序 它需要连接到我的 mysql 数据库并使用 json 返回数据 这很好 目前我有一个登录系统 一旦确定用户名和密码存在 它就会返回一条成功消息 对于下一步 我想在我的页面上使
  • 如何从浏览器向服务器发送“页面将关闭”消息?

    我想向每个 html 文档添加一个脚本 JavaScript 该脚本向服务器发送两条消息 页面确实打开了 页面将关闭 此消息包含页面打开的时间 打开消息应在文档加载时 或加载完成时 发送 这是简单的部分 The close message

随机推荐