源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

IONIC自定义subheader的最佳解决方案

  • 时间:2022-12-13 16:12 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:IONIC自定义subheader的最佳解决方案
IONIC subheader是我们常用的一个css 属性,但是这个subheader的高度是固定的,当然也是可以改变的,但是如果改了subheader的告诉,还要更改content的top值,稍微有些麻烦,如果是动态告诉的subheader就麻烦了,还需要动态更改content的top数值,所以就写了一个directive解决这个问题: 上代码吧: [b]主要代码[/b]
/**
* Created by Richard on 9/21/16.
*/
'use strict';
// @ngInject
module.exports = function() {
return {
link: function(scope, element, attrs) {
scope.$watch(function() {
let height = element[0].offsetHeight + 44;
let content = angular.element(document.querySelector('.has-subheader'));
content.css("top", height + "px");
});
}
}
};
[b]定义directie:[/b]
.directive('customSubheader', customSubheader)
[b]重写css:[/b]
.bar-subheader {
height: auto;
}
[b]使用方法:[/b]
<div custom-subheader class="bar bar-subheader">
</div>
以上所述是小编给大家介绍的IONIC自定义subheader的最佳解决方案,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对编程素材网网站的支持!
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部