我正在使用 AngularJS 和 Bootstrap,并具有以下结构:
<parent-div>
<flexible-width-component
class="pull-left"
style="display: inline-block; min-width: 700px;">Data grid with many columns
</flexible-width-component>
<fixed-width-component
class="pull-right"
style="width:400px; display: inline-block">
</fixed-width-component>
</parent-div>
我希望拥有我的flexible-width-component
拉伸以自动填充自身与对象之间的间隙fixed-width-component
,对于任何宽于的分辨率1200px
。
两个组件需要彼此相邻显示。
任何建议都非常感谢!
你可以获得你的父容器offsetWidth
并从中减去你的固定宽度:
var example = angular.module('exmp', []);
example.directive('flexibleWidth', function() {
return function(scope, element, attr) {
// Get parent elmenets width and subtract fixed width
element.css({
width: element.parent()[0].offsetWidth - 400 + 'px'
});
};
});
Here's a demo http://jsbin.com/oHOdeMox/1
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)