0

I have problems to set the width of my XUL button. I have this code:

<button label="Ok" width="16" maxwidth="16" height="16" maxheight="16"/>

By with that code, the size of my entire window is changed and not only the button.

And when I write that :

<button label="Ok" width="16" height="16"/>

Only the height is changed. Why is that?

4

1 回答 1

1

XUL 使用灵活的盒子模型进行定位。width和属性定义元素的height固有大小,而不是显示它们的大小。您的按钮显然放置在一个垂直框中(不一定是实际vbox元素,而是任何带有 的元素orient="vertical")。默认情况下,盒子的align属性被假定为具有值stretch- 所以垂直盒子总是会水平拉伸其中的元素:

<vbox>
  <!-- this button is stretched horizontally to match the width of its container -->
  <button label="Ok" width="16" height="16"/>
</vbox>

您可以align显式设置属性以避免这种情况:

<vbox align="center">
  <!-- this button is centered inside its container -->
  <button label="Ok" width="16" height="16"/>
</vbox>
于 2013-04-26T07:14:40.990 回答