1

如何在使用 threepenny-gui 包创建的 GUI 中更改按钮或其他 UI 元素的大小和位置?

文档Graphics.UI.Threepenny.Attributes列出了一些可能有用的函数,例如coords :: WriteAttr Element String. 但是,我不明白如何使用它们。具体来说,我不明白这个String论点应该是什么。

谢谢

4

2 回答 2

0

Threepenny UI element combinators translate more or less directly to HTML, and so you should think in terms of HTML when doing layout with it:

  • The attributes from Graphics.UI.Threepenny.Attributes you mention are HTML attributes. Modifying them while defining your initial layout is typically done with set. (By the way, if you need a reference for looking up what things like HTML attributes do, you can't do wrong with MDN.)

  • For CSS styling, you can use the (#.) combinator.

  • As for layout, the basic tools are (#+) to nest HTML elements, and grid, row and column to arrange div-based grids.

于 2019-04-23T22:39:09.780 回答
0

我认为我的误解是我的问题实际上与 threepenny-gui 无关,而是关于 HTML 的问题。此链接帮助我找到了我正在寻找的答案:https ://www.geeksforgeeks.org/html-attributes/

以防万一其他人也为此苦苦挣扎,这条线(主要)解决了它:

# set UI.style [("text-align", "center"),("color","red"),("font-size","30px")]

(UI.style 中的 UI 来自import qualified Graphics.UI.Threepenny as UI:)

于 2019-04-23T22:20:23.977 回答