Ult*_*nja 6 popover twitter-bootstrap angularjs angular-ui-bootstrap
我试图改变的背景颜色引导UI酥料饼通过创建自定义酥料饼类重写现有的(如popover1,popover2等代替popover).我知道这适用于vanilla Bootstrap popovers(这里是小提琴,但它似乎不适用于Bootstrap UI popovers).
当我将相同的方法应用于Bootstrap UI popover时,它只显示一个很小的空白弹出窗口.到目前为止,我所做的就是改变
<a class="btn btn-primary popover-container" id="popover" data-toggle="popover" data-placement="right" data-container="body" rel="log-popover">Log level</a>
Run Code Online (Sandbox Code Playgroud)
至
<a class="btn btn-primary popover-container" popover-placement="right" popover-template="'partials/loglevel-template.html'" popover-trigger="click">Log level</a>
Run Code Online (Sandbox Code Playgroud)
日志等级,template.html
<div class="popover1">
<div class="arrow"></div>
<div class="popover-content">
<p>some content</p>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
当我删除popover1它的类时,所以没有功能问题只是让弹出窗口显示.
我更喜欢使用Bootstrap UI popovers,因为你不必在jQuery中使用任何硬编码模板tomfoolery(事实上你根本不需要编写任何jQuery).我只是无法弄清楚如何更改Bootstrap UI popovers的背景颜色.在我走下兔洞之前,我想知道是否有其他人已经实现了这一点,或者是否有一个简单的修复(也许Bootstrap UI popovers使用一组不同于vanilla popovers的类).如果这是一个覆盖一些CSS类的问题,那将是梦想.
不幸的是,UI Bootstrap 文档中没有记录这一点,而且我(也不幸的是)花了几个小时才找到这个极其简单的解决方案,但希望这会节省其他人一些时间。您可以popover-class向放置uib-popover指令的元素添加属性,然后相应地设置弹出框的样式。有关详细信息,请参阅下面的片段:
angular.module('ui.bootstrap.demo', ['ngAnimate', 'ui.bootstrap']);
angular.module('ui.bootstrap.demo').controller('PopoverDemoCtrl', function ($scope, $sce) {
$scope.dynamicPopover = {
content: 'Hello, World!',
templateUrl: 'myPopoverTemplate.html',
title: 'Title'
};
});Run Code Online (Sandbox Code Playgroud)
.trigger-popover-button {
margin: 25% 0 0 10%;
}
.custom-dynamic-popover-class {
color: red;
}
.custom-dynamic-popover-class > .popover-inner > .popover-title {
background: yellow;
}
.custom-dynamic-popover-class > .popover-inner > .popover-content {
background: blue;
}Run Code Online (Sandbox Code Playgroud)
<!doctype html>
<html ng-app="ui.bootstrap.demo">
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular-animate.js"></script>
<script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-1.3.3.js"></script>
<script src="example.js"></script>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div ng-controller="PopoverDemoCtrl">
<button uib-popover-template="dynamicPopover.templateUrl"
popover-title="{{dynamicPopover.title}}"
popover-class="custom-dynamic-popover-class"
type="button"
class="btn btn-default trigger-popover-button">
Popover With Template
</button>
<script type="text/ng-template" id="myPopoverTemplate.html">
<div>{{dynamicPopover.content}}</div>
<div class="form-group">
<label>Popup Title:</label>
<input type="text"
ng-model="dynamicPopover.title"
class="form-control">
</div>
</script>
</div>
</body>
</html>Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2276 次 |
| 最近记录: |