使用 fx:Style 设置按钮宽度
我有 4 个按钮,它们的宽度都相同。
<s:Button id="btn1" width="{btnWidth}" />
<s:Button id="btn2" width="{btnWidth}" />
<s:Button id="btn3" width="{btnWidth}" />
<s:Button id="btn4" width="{btnWidth}" />
是否可以使用 Style
设置它们的宽度,如下所示:
s|Button{
width: btnWidth;
}
我尝试过,但自动完成功能不起作用,这让我认为语法有问题。基本上我的目标是不专门为所有 4 个设置 width
属性。
I have 4 buttons, all of them have the same width.
<s:Button id="btn1" width="{btnWidth}" />
<s:Button id="btn2" width="{btnWidth}" />
<s:Button id="btn3" width="{btnWidth}" />
<s:Button id="btn4" width="{btnWidth}" />
Is it possible to set their width with Style
, something like this:
s|Button{
width: btnWidth;
}
I tried it, but auto-complete isn't working, which leads me to think that there's something wrong with the syntax. Basically my goal is to not have the width
property set specifically for all 4.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它不能开箱即用,因为宽度是按钮的属性,而不是样式。您只能在样式表中指定样式。
但是,您可以做的是扩展 Button 并添加控制按钮宽度的样式。
It won't work out of the box because width is a property of button, not a style. You can only specify styles in your stylesheet.
However, what you can do is extending Button and add a style that controls the width of your button.