作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
一旦我设置了 width
或 percentWidth
flex 标签上的属性,有没有办法将宽度重置为其默认值(即文本加内边距的宽度)?
我使用标签作为渲染器。在某些情况下,我希望它自动调整文本大小,而在其他情况下,我希望它是其容器的百分比宽度。显然,我可以使用两个单独的标签,一个用于上述每种情况,但我很好奇是否可以将标签重置为其默认行为。
最佳答案
label.width = NaN;
//not sure if the following lines are required
label.invalidateSize();
label.width = label.measuredWidth;
When you set a specific height and width of a component, Flex does not call the measure() method, even if you explicitly call the invalidateSize() method. That is, Flex only calls the measure() method if the explicitWidth property or the explicitHeight property of the component is NaN.
关于apache-flex - 设置显式宽度后将 flex 标签宽度重置为 "auto"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1554851/
我是一名优秀的程序员,十分优秀!