Align image center

We need to align an image to the center of the sail form, we tried adding the image to a section with one column but the image appears at the left of the screen.

Thank you for your time.

Add an example image

Bye ;-)

OriginalPostID-254017



  Discussion posts and replies are publicly visible

Parents
  • As mentioned by Tajinder, there is no direct way. However, we can exploit the editable grid or the paging grid to align the image to center. The idea is to give the columns weight with the center one having higher weight than the other two columns. and use alignments.
    Here's a sample code, (Note: replace the number 3886 with docId of an image):
    a!gridLayout(
    labelPosition: "ABOVE",
    headerCells: {
    a!gridLayoutHeaderCell(align: "RIGHT"), a!gridLayoutHeaderCell(align: "CENTER"),a!gridLayoutHeaderCell(align: "LEFT")
    },
    columnConfigs: {
    a!gridLayoutColumnConfig( weight: "3"),
    a!gridLayoutColumnConfig(weight: "4"),
    a!gridLayoutColumnConfig(weight: "3")
    },
    rows: {
    a!gridRowLayout(
    contents: {
    a!textField(readOnly: true,disable: true),
    a!imageField(
    images: { a!documentImage(document: 3886)}
    ),
    a!textField(readOnly: true,disable: true)
    }
    )
    },
    selectionSaveInto: {},
    validations: {}
    )
    This does align the image to the center of the page. And if you are using Sites, it will be exactly at the center. It also works on mobile display. I tried different resolutions in chrome browser, and the image always remained in the center. I am attaching a screenshot of what the result looks like.
    Note: instead of editable grid, you could also use paging grid and employ a similar trick. But, paging grid gives a slightly grey background to the columns. Hence editable grid would be better.(end-user wont be able to make out that its a grid since we are not showing any text) This is of-course a hack, but could be used.

Reply
  • As mentioned by Tajinder, there is no direct way. However, we can exploit the editable grid or the paging grid to align the image to center. The idea is to give the columns weight with the center one having higher weight than the other two columns. and use alignments.
    Here's a sample code, (Note: replace the number 3886 with docId of an image):
    a!gridLayout(
    labelPosition: "ABOVE",
    headerCells: {
    a!gridLayoutHeaderCell(align: "RIGHT"), a!gridLayoutHeaderCell(align: "CENTER"),a!gridLayoutHeaderCell(align: "LEFT")
    },
    columnConfigs: {
    a!gridLayoutColumnConfig( weight: "3"),
    a!gridLayoutColumnConfig(weight: "4"),
    a!gridLayoutColumnConfig(weight: "3")
    },
    rows: {
    a!gridRowLayout(
    contents: {
    a!textField(readOnly: true,disable: true),
    a!imageField(
    images: { a!documentImage(document: 3886)}
    ),
    a!textField(readOnly: true,disable: true)
    }
    )
    },
    selectionSaveInto: {},
    validations: {}
    )
    This does align the image to the center of the page. And if you are using Sites, it will be exactly at the center. It also works on mobile display. I tried different resolutions in chrome browser, and the image always remained in the center. I am attaching a screenshot of what the result looks like.
    Note: instead of editable grid, you could also use paging grid and employ a similar trick. But, paging grid gives a slightly grey background to the columns. Hence editable grid would be better.(end-user wont be able to make out that its a grid since we are not showing any text) This is of-course a hack, but could be used.

Children
No Data