使用 fx:Style 设置按钮宽度

发布于 2024-09-03 07:49:30 字数 429 浏览 5 评论 0原文

我有 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱格式化 2024-09-10 07:49:30

它不能开箱即用,因为宽度是按钮的属性,而不是样式。您只能在样式表中指定样式。

但是,您可以做的是扩展 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文