gpt4 book ai didi

html - Bootstrap : 100% height div inside a th with rowspan

转载 作者:行者123 更新时间:2023-11-28 04:39:41 28 4
gpt4 key购买 nike

我在某些 th 上有一个包含 rowspan="2" 的表格。我想在用户将鼠标放在此 th 上的任意位置时显示 Bootstrap 工具提示,但总是有一些自动填充,即使我删除了填充。这会在 th 内创建一个区域,该区域不会激活工具提示。

我也在使用 jQuery tablesorter。

th > div {
width: 100%;
height: 100%;
}
.tooltip-th {
margin: -5px;
padding: 5px 0;
}
.table > thead > tr > th {
vertical-align: middle;
}
<html>

<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
<script src="http://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
</head>

<body>
<table class="table well table-condensed table-bordered table-hover table-striped sorter">
<thead>
<tr>
<th rowspan="2">
<div data-toggle="tooltip" data-placement="bottom" title="Tooltip test">
Column title
</div>
</th>
<th>
Column title 2
</th>
</tr>
<tr>
<th>
Column title 3
</th>
</tr>
</thead>
</table>
</body>

</html>

最佳答案

那是因为你的 <div>没有填满整个 <th>所以将你的工具提示移动到 <th> . (请参阅下面大写代码中我的代码更改)。不要尖叫只是为了突出我的变化 :) 和平!

PS:添加了 Lime 背景颜色以显示边界位置。添加背景颜色总是一个好主意,这样您就可以看到自己在做什么。

另一个很酷的技巧是将其放入您的 CSS 文件中以显示边界。

* {border: 1px solid red}

(仅在重置框时有效: https://www.paulirish.com/2012/box-sizing-border-box-ftw/ )

th > div {
width: 100%;
height: 100%;
}
.tooltip-th {
margin: -5px;
padding: 5px 0;
}
.table > thead > tr > th {
vertical-align: middle;
}
<html>

<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
<script src="http://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
</head>

<body>
<table class="table well table-condensed table-bordered table-hover table-striped sorter">
<thead>
<tr>
<th rowspan="2" TITLE="PLACE YOUR TOOLTIP HERE.">
<div STYLE="BACKGROUND-COLOR: LIME;" data-toggle="tooltip" data-placement="bottom" title="not here...">
Column title
</div>
</th>
<th>
Column title 2
</th>
</tr>
<tr>
<th>
Column title 3
</th>
</tr>
</thead>
</table>
</body>

</html>

关于html - Bootstrap : 100% height div inside a th with rowspan,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41279360/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com