javascript 离子:如何在 $ionicPopup 中使用 cssClass?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32636833/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Ionic: how to use cssClass in $ionicPopup?
提问by Batzi
So I want to modify the default width in $ionicPopup and to do so I have to add 'cssClass' to my popup object just like the code below
所以我想修改 $ionicPopup 中的默认宽度,为此我必须像下面的代码一样将“cssClass”添加到我的弹出对象中
$scope.getScore = function(){
var popupScore = $ionicPopup.alert({
title:'Score',
template: 'Total XP points: 50',
cssClass: '',
buttons: [{
text:'Return',
type: 'button-assertive'
}]}}
How would you proceed in this case? Should I give cssClass a value? (i.e: cssClass = 'popupClass') and then go to my CSS file and modify the width from there?
在这种情况下,您将如何处理?我应该给 cssClass 一个值吗?(即:cssClass = 'popupClass')然后转到我的 CSS 文件并从那里修改宽度?
回答by Mudasser Ajaz
Just define a mother class and override .popup default ionic class inside this way
只需定义一个母类并以这种方式覆盖 .popup 默认离子类
.my-custom-popup{
.popup{
//styling for popup width, width: 300px;
}
.popup-title{
//styling for title
}
}
and pass my-custom-popup
in cssClass
并通过my-custom-popup
在 cssClass
var popupScore = $ionicPopup.alert({
title:'Score',
template: 'Total XP points: 50',
cssClass: 'my-custom-popup',
buttons: [{
text:'Return',
type: 'button-assertive'
}]}}
Here is the list of classes which you can override or customize in your parent class
这是您可以在父类中覆盖或自定义的类列表
.popup
.popup-head
.popup-title
.popup-sub-title
.popup-body
.popup-buttons.row
.popup-buttons .button
。弹出
.popup-head
.popup-title
.popup-sub-title
.popup-body
.popup-buttons.row
.popup-buttons .button