1

我们的页面呈现如下内容: 在此处输入图像描述

有没有办法更好地格式化这个?例如,可能在一列中有标签,而在另一列中有输入?

这是我们的代码片段:

renderContentOn: html

    html horizontalRule.
    html horizontalRule.
    html heading level: 2; with: 'System Warnings & Errors:'.
    html horizontalRule.
    (SpendingManager warningsFound = false) ifFalse: [ 
        self renderWarnings.
        WarningsReport renderContentOn: html.
        SpendingManager clearProblemList.

    html horizontalRule.
    html horizontalRule.
    ].

        html heading level: 2; with: 'Create A Fund:'.
            html form: [
            html label: 'Code:  '.
            html textInput
            on: #fName of: FundCreator.
                html break.
            html label: '   Starting Amount:  '.
            html textInput
            on: #amount of: FundCreator.
                html break.

        html submitButton
            callback: [(FundCreator fName = '') ifFalse: [FundCreator createFromUI.] 
                                                ifTrue: [SpendingManager addProblem: 'SP0002']. 
            self renderReport ];
            text: 'Create Fund'.
        ].

        html heading level: 2; with: 'Create A GLAC:'.
        html form: [

            html label: 'Code:  '.
            html textInput
            on: #gName of: GLACCreator.
                html break.

            html label: '   Debit Fund:  '.
            html textInput
            on: #dFund of: GLACCreator.
                html break.

            html label: '   Credit Fund:  '.
            html textInput
            on: #cFund of: GLACCreator.
                html break.

            html label: '   Description:  '.
            html textInput
            on: #descr of: GLACCreator.
                html break.

        html submitButton
            callback: [GLACCreator createFromUI. self renderReport ];
            text: 'Create GLAC'.

    ].

        html heading level: 2; with: 'Create a Transaction:'.
        html form: [

            html label: 'GLAC:  '.
            html textInput
            on: #aGLAC of: TransactionCreator.
                html break.

            html label: '   Amount:  '.
            html textInput
            on: #amount of: TransactionCreator.
                html break.

        html submitButton
            callback: [TransactionCreator createFromUI. self renderReport ];
            text: 'Create Transaction'.

    ].
4

2 回答 2

3

您可以做几件事。

更简单的方法是呈现一个表格并将所有标签放入一列,将文本输入放入另一列。您将使用 css 使表格和单元格边框不可见。

更好的解决方案是为标签分配一个 css 类,然后再次使用 css 使所有标签具有相同的大小和方向。

于 2013-07-17T03:44:44.053 回答
0

绝对在 CSS 中执行此操作,这就是它的用途。您可以设置标签和输入元素以显示为块,然后使用宽度和对齐方式获得您想要的布局。

这样的事情应该让你开始:

form label {
  display: block;
  float: left;
  text-align: right;
  padding-right: 1em;
  padding-top: 0.3em;

  width: 15em;
}

form input {
  display: block;
  float: left;
  padding-top: 0.3em;
}

form br {
  clear: left;
}
于 2013-08-14T10:25:51.083 回答