如何仅在需要时显示Bootstrap 3 popover

Val*_* S. 6 html css scroll popover twitter-bootstrap

我有这个popover,有一个滚动条

HTML

<ul class="navbar-nav pull-right"> 
<li><a href="#" data-toggle="popover" title="Notifications" data-html="true" data-content="<a href='?Profile'><div class='pop-text'>Notification 1</div></a><hr /><a href='?Profile'><div class='pop-text'>Notification 2</div></a><hr /><a href='?Profile'><div class='pop-text'>Notification 3</div></a><hr /><a href='?Profile'><div class='pop-text'>Notification 4</div></a><hr /><div><p id='foot-notification-pop'><a href='?notification'>Show all</a></p></div>">Notification</a></li>
</ul>
Run Code Online (Sandbox Code Playgroud)

CSS

.popover-content {
  height: 200px;
  overflow-y: scroll;
 }
Run Code Online (Sandbox Code Playgroud)

我想只在需要时显示滚动条,只有当popover内容的高度超过200px的高度时才会显示.当滚动条始终显示时,但当高度小于200px时,不可点击(当然).我该怎么做?任何帮助将不胜感激.谢谢!

小智 8

你可以用overflow:auto.在这里阅读更多关于溢出属性


win*_*oy5 5

将overflow-y设置为auto.仅当内容超过200px高度时,才会显示滚动.

"overflow-y: auto;"
Run Code Online (Sandbox Code Playgroud)

这应该工作.