我正在使用 ExtJs。
有没有办法根据其项目来调整Ext.Window
的宽度?
高度会自动调整为“auto”,但width:'auto'
会将其扩展到整个浏览器窗口。
var childPnl1 = { // 1
frame: true,
width: 350,
height: 50,
html: 'My First Child Panel',
title: 'First children are fun'
}
var childPnl2 = { // 2
width: 150,
html: 'Second child',
title: 'Second children have all the fun!'
}
new Ext.Window({
renderTo: Ext.getBody(),
items: [
childPnl1,
childPnl2,
{
title: '3rd',
width: 400, //Maximum
height: '150',
frame: true
}
]
});
现在我需要一种方法让窗口将其宽度调整为 400。
一种方法是迭代所有面板
,然后获得最右边的边缘,但我想避免这种情况。
最佳答案
当然它会扩展到整个浏览器窗口,为什么你不使用公共(public)变量呢? 项目宽度和窗口宽度?此外,它还能保证您的窗口大小既不大于也不小于项目宽度。有时在不同的情况下,autoWidth 的行为会有所不同。因此最好使用手动宽度。
关于javascript - 如何根据其内容调整ExtJS窗口宽度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9822341/