我想制作一个涵盖表格的弹出窗口
<!DOCTYPE html>
<html>
<head>
<title>JS Bin</title>
<script src="https://code.jquery.com/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<style>
.popover {
width: 2000px;
}
.popover-table th, td {
padding: 0px 15px;
white-space:nowrap;
}
</style>
</head>
<body>
<a href="#" data-toggle="popover4">4</a>
<div id="popover4-html" style="display: none">
abcdefghi:
<table class="popover-table">
<tr></tr>
<tr>
<th>alongtitleisverylong</th>
<th>linked to event3</th>
<th>100 lines</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
</table>
</div>
<script>
$('[data-toggle="popover4"]').popover({
html: true,
content: function() {
return $("#popover4-html").html()
}});
</script>
</body>
</html>
有两个问题:
1)弹出窗口的宽度不能覆盖桌子的宽度</ p>
2)我不想在表格的第一行加粗,但我不知道怎么做
有人可以帮忙吗?
答案 0 :(得分:0)
您可以使用以下代码
<!DOCTYPE html>
<html>
<head>
<title>JS Bin</title>
<script src="https://code.jquery.com/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<style>
.popover {
width: 2000px;
max-width:50%
}
.popover-table th, td {
padding: 0px 15px;
white-space:nowrap;
}
</style>
</head>
<body>
<a href="#" data-toggle="popover4">4</a>
<div id="popover4-html" style="display: none">
abcdefghi:
<table class="popover-table">
<tr></tr>
<tr>
<td>alongtitleisverylong</td>
<td>linked to event3</td>
<td>100 lines</td>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
</table>
</div>
<script>
$('[data-toggle="popover4"]').popover({
html: true,
content: function() {
return $("#popover4-html").html();
}});
</script>
</body>
</html>
&#13;
<th>
标记将始终加粗其中的文字,因此我将其替换为<td>
标记。
poppos类中的max-width在bootstrap.css中给出为276px,所以我通过用max-width替换它来覆盖它:50%。