twitter-bootstrap Bootstrap 在鼠标悬停时显示 div

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/45493245/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 00:58:16  来源:igfitidea点击:

Bootstrap show div on mouse hover

jquerycsstwitter-bootstraptwitter-bootstrap-3mousehover

提问by user2972061

Is there any way to show Divon mouse hover on any html elements like td

有什么方法可以Div在鼠标悬停在任何 html 元素上时显示,例如td

Div has the HTML content in it.

Div 中有 HTML 内容。

enter image description here

在此处输入图片说明

回答by MercyDude

There is "Bootstrap Popover Plugin" : https://www.w3schools.com/bootstrap/bootstrap_popover.asp

有“Bootstrap Popover Plugin”:https://www.w3schools.com/bootstrap/bootstrap_popover.asp

like that:

像那样:

  <div class="container">
  <h3>Popover Example</h3>
  <a href="#" title="Header" data-toggle="popover" data-trigger="hover" data-content="Some content">Hover over me</a>
  </div>

<script>
$(document).ready(function(){
    $('[data-toggle="popover"]').popover();   
});
</script>

Another example on table element: (hover "Savings")

表格元素的另一个例子:(悬停“储蓄”)

https://jsfiddle.net/yrgLenjg/

https://jsfiddle.net/yrgLenjg/

回答by Stanley Liu

You can do this with CSS.

你可以用 CSS 做到这一点。

Example HTML:

示例 HTML:

<div id="to-hover">
    <div id="to-show"></div>
</div>

Example CSS:

示例 CSS:

#to-show {
    display: none;
}
#to-hover:hover > #to-show {
    display: block; 
}

You may need to change block to inline or some other value depending on the situation. Also you might need to use a different selector than >if they divs have a different relationship.

您可能需要根据情况将块更改为内联或其他值。此外,您可能需要使用不同的选择器,而不是>它们的 div 具有不同的关系。