我最近一直在研究 Cappuccino 和 Atlas,它们似乎将相对和绝对定位抽象为“有效”的东西。我想知道熟悉该项目的人 - 他们是如何做到这一点的?
我一直认为相对和绝对定位是一种晦涩的思考定位元素的方式,所以我对此很好奇。
我可以查看的任何帮助或资源都非常棒!
最佳答案
Cappuccino 使用 Cocoa View 模型。在常规 HTML 中,重点在于文本的布局,这就是为什么您可以使用“ float ”之类的东西来将一个文本 block 粘贴到另一个文本 block 中。
在 Cappuccino 中,对象的定位和大小更像桌面。您可以将小部件放置在具有固定坐标的“ View ”层次结构中,并将它们“锚定”到屏幕的一侧或多侧(或父 View )。
这就像在 Cocoa 中一样,所以只需看看它在 Interface Builder 中是如何描述的:
The springs and struts in the autosizing control define the selected view’s relationship to its parent frame. A spring causes the view to resize itself proportionally based on the width or height of its superview. A strut causes the view to maintain a fixed distance between itself and its superview along the given edge.
当然,在幕后,这一切都归结为使用 JavaScript 进行常规绝对定位来执行调整大小模型。
关于positioning - Cappuccino (objective-j)/Atlas 如何从图片中提取相对和绝对定位?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3902691/