2
A
回答
1
我不认为有直接的方式,但你可以做这样的事情(它实际上水平和垂直居中):
Shoes.app do
@s=stack :width=>300, :height=>100, do
background red
end
@top=(@[email protected][:height])/2
@left=(@[email protected][:width])/2
@s.move(@left,@top)
end
你或许可以把它包装在一个功能更容易使用:
def center(elem)
top=(elem.parent.height-elem.style[:height])/2
left=(elem.parent.width-elem.style[:width])/2
elem.move(left,top)
end
,然后用它这样的:
...
@s=stack :width=>300, :height=>100, do
background red
end
center(@s)
...
..或者你可以扩展Stack类这样的:
class Shoes::Types::Stack
def center
top=(self.parent.height-self.style[:height])/2
left=(self.parent.width-self.style[:width])/2
self.move(left,top)
end
end
,比使用这样的:
@s=stack :width=>300, :height=>100, do
background red
end
@s.center
ķ
相关问题
- 1. 对齐堆栈标签
- 2. Qt,GCC,SSE和堆栈对齐
- 3. 对齐堆栈是什么意思?
- 4. 堆栈分配,填充和对齐
- 5. WPF堆栈面板居中对齐
- 6. Visual Studio 2008未对齐堆栈变量?
- 7. 从堆栈指针减去对齐?
- 8. 对齐堆栈上的数据(C++)
- 9. STDCALL和CDECL堆栈对齐尺寸
- 10. 缓存对齐的堆栈变量
- 11. 垂直对齐堆栈内容
- 12. 对齐或不对齐堆栈上的char数组?
- 13. 关于堆栈帧的对齐,来自CSAPP的一个例子
- 14. 堆栈应该如何使用大对象堆栈?
- 15. 使用堆栈的素因子分解
- 16. 堆栈在子对话框调用context.Done时是空的错误
- 17. c&gcc:堆栈增长和对齐 - 对于64位机器
- 18. C++:使用堆栈
- 19. 堆栈使用类
- 20. ASM堆栈使用
- 21. 堆栈使用Pam.d
- 22. MIPS:使用堆栈
- 23. printf使用堆栈?
- 24. 对C++堆栈使用感到困惑
- 25. 使用Retrofit时堆栈溢出rxjava concatWith
- 26. 使用CORBA时打印堆栈跟踪
- 27. 使用TSQLConnection.SetTraceEvent时堆栈损坏?
- 28. 汇编器堆栈对齐(或更好的与PUSH不一致的例子)
- 29. 鞋子安装
- 30. 鞋子提示?