当有很多弹出窗口时,如果我想触发那些使用'手册',那么只有top&底部将显示在适当的位置。如果放置是向右或向左,则它是未对齐的。请看看这个小提琴......
https://jsfiddle.net/6nz4u940/
<html>
<head>
<title>Try v1.2 Bootstrap Online</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-1.12.0.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<script type="text/javascript">
function popit(){
console.log("fddffdg");
$("[data-content]").each(function () {
$(this).attr({"data-container":"body","data-trigger":"manual","data-toggle":"popover"});
$(this).popover('toggle');
});
}
</script>
</head>
<body>
<button onclick="popit()">click me and scroll down, i wont show all popover</button>
<div class = "container" style = "padding: 100px 50px 10px;" >
<button type = "button" class = "btn btn-default" title = "Popover title"
data-container = "body" data-toggle = "popover" data-placement="right"
data-content = "Some content in Popover on left">
Popover on left
</button>
<br><br><br><br><br><br><br><br>
<button type = "button" class = "btn btn-default" title = "Popover title"
data-container = "body" data-toggle = "popover" data-placement="right"
data-content = "Some content in Popover on left">
Popover on left
</button>
<br><br><br><br><br><br><br><br>
<button type = "button" class = "btn btn-default" title = "Popover title"
data-container = "body" data-toggle = "popover" data-placement="right"
data-content = "Some content in Popover on left">
Popover on left
</button>
<br><br><br><br><br><br><br><br>
<button type = "button" class = "btn btn-default" title = "Popover title"
data-container = "body" data-toggle = "popover" data-placement="right"
data-content = "Some content in Popover on left">
Popover on left
</button>
<br><br><br><br><br><br><br><br>
<button type = "button" class = "btn btn-default" title = "Popover title"
data-container = "body" data-toggle = "popover" data-placement="right"
data-content = "Some content in Popover on left">
Popover on left
</button>
<br><br><br><br><br><br><br><br>
<button type = "button" class = "btn btn-default" title = "Popover title"
data-container = "body" data-toggle = "popover" data-placement="right"
data-content = "Some content in Popover on left">
Popover on left
</button>
<br><br><br><br><br><br><br><br>
<button type = "button" class = "btn btn-default" title = "Popover title"
data-container = "body" data-toggle = "popover" data-placement="right"
data-content = "Some content in Popover on left">
Popover on left
</button>
<br><br><br><br><br><br><br><br>
<button type = "button" class = "btn btn-default" title = "Popover title"
data-container = "body" data-toggle = "popover" data-placement="right"
data-content = "Some content in Popover on left">
Popover on left
</button>
<br><br><br><br><br><br><br><br>
<button type = "button" class = "btn btn-default" title = "Popover title"
data-container = "body" data-toggle = "popover" data-placement="right"
data-content = "Some content in Popover on left">
Popover on left
</button>
<br><br><br><br><br><br><br><br>
<button type = "button" class = "btn btn-default" title = "Popover title"
data-container = "body" data-toggle = "popover" data-placement="right"
data-content = "Some content in Popover on left">
Popover on left
</button>
<br><br><br><br><br><br><br><br><button type = "button" class = "btn btn-default" title = "Popover title"
data-container = "body" data-toggle = "popover" data-placement="right"
data-content = "Some content in Popover on left">
Popover on left
</button>
<br><br><br><br><br><br><br><br>
<button type = "button" class = "btn btn-default" title = "Popover title"
data-container = "body" data-toggle = "popover" data-placement="right"
data-content = "Some content in Popover on left">
Popover on left
</button>
<br><br><br><br><br><br><br><br>
<button type = "button" class = "btn btn-default" title = "Popover title"
data-container = "body" data-toggle = "popover" data-placement="right"
data-content = "Some content in Popover on left">
Popover on left
</button>
<br><br><br><br><br><br><br><br>
<button type = "button" class = "btn btn-default" title = "Popover title"
data-container = "body" data-toggle = "popover" data-placement="right"
data-content = "Some content in Popover on left">
Popover on left
</button>
<br><br><br><br><br><br><br><br>
<button type = "button" class = "btn btn-default" title = "Popover title"
data-container = "body" data-toggle = "popover" data-placement="right"
data-content = "Some content in Popover on left">
Popover on left
</button>
<br><br><br><br><br><br><br><br>
<button type = "button" class = "btn btn-default" title = "Popover title"
data-container = "body" data-toggle = "popover" data-placement="right"
data-content = "Some content in Popover on left">
Popover on left
</button>
<br><br><br><br><br><br><br><br>
<button type = "button" class = "btn btn-default" title = "Popover title"
data-container = "body" data-toggle = "popover" data-placement="right"
data-content = "Some content in Popover on left">
Popover on left
</button>
<br><br><br><br><br><br><br><br>
<button type = "button" class = "btn btn-default" title = "Popover title"
data-container = "body" data-toggle = "popover" data-placement="right"
data-content = "Some content in Popover on left">
Popover on left
</button>
<br><br><br><br><br><br><br><br>
<button type = "button" class = "btn btn-default" title = "Popover title"
data-container = "body" data-toggle = "popover" data-placement="right"
data-content = "Some content in Popover on left">
Popover on left
</button>
<br><br><br><br><br><br><br><br>
<button type = "button" class = "btn btn-default" title = "Popover title"
data-container = "body" data-toggle = "popover" data-placement="right"
data-content = "Some content in Popover on left">
Popover on left
</button>
<br><br><br><br><br><br><br><br>
<button type = "button" class = "btn btn-default" title = "Popover title"
data-container = "body" data-toggle = "popover" data-placement="right"
data-content = "Some content in Popover on left">
Popover on left
</button>
<br><br><br><br><br><br><br><br>
<button type = "button" class = "btn btn-primary" title = "Popover title"
data-container = "body" data-toggle = "popover" data-placement = "top"
data-content = "Some content in Popover on top">
Popover on top
</button>
<button type = "button" class = "btn btn-success" title = "Popover title"
data-container = "body" data-toggle = "popover" data-placement = "bottom"
data-content = "Some content in Popover on bottom">
Popover on bottom
</button>
<button type = "button" class = "btn btn-warning" title = "Popover title"
data-container = "body" data-toggle = "popover" data-placement = "right"
data-content = "Some content in Popover on right">
Popover on right
</button>
</div>
<script>
$(function (){
$("[data-toggle = 'popover']").popover();
});
</script>
</body>
</html>
答案 0 :(得分:2)
您可以使用viewport
选项解决此问题..
$("[data-content]").popover({
trigger:"manual",
viewport:".container"
});