tipsy / j2html

Java to HTML generator. Enjoy typesafe HTML generation.

Home Page:https://j2html.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

img width/height and h2 align="center"

afarber opened this issue · comments

Good evening,

I have 2 questions for j2html 1.4.0 please:

When trying to translate the following piece of HTML:

        <H2 ALIGN="center">List of players</H2>
        <TABLE ID="ratingTable" CLASS="stripe" STYLE="min-width: 480px;">
            <THEAD>
                <TR>
                    <TH>Elo</TH>
                    <TH>Name</TH>
                    <TH>Photo</TH>
                </TR>
            </THEAD>
            <TBODY>
            </TBODY>
        </TABLE>

        <H2 ALIGN="center">List of games</H2>
        <DIV ID="gamesChart" CLASS="gchart"><IMG SRC="/images/loader.gif" WIDTH="60" HEIGHT="60"></DIV>
  1. How to create h2().withAlign("center") (method not found) ?

  2. And how to specify the img dimensions? There is no img().withWidth()

Here is what I've tried sofar:

        ContainerTag div = div(
                h2("List of players").withStyle("margin: auto;"),
                table(
                        thead(
                                tr(
                                        th("Elo"),
                                        th("Name"),
                                        th("Photo")
                                )
                        ),
                        tbody()
                ).withId("ratingTable").withClass("stripe").withStyle("min-width: 480px;"),
                h2("List of games").withStyle("margin: auto;"),
                div(
                        img().withSrc("/images/loader.gif").withWidth(60)
                ).withId("gamesChart").withClass("gchart")
        );

Thank you
Alex

Nevermind - I have found the solution:

        ContainerTag div = div(
                h2("List of players").attr("align", "center"),
                table(
                        thead(
                                tr(
                                        th("Elo"),
                                        th("Name"),
                                        th("Photo")
                                )
                        ),
                        tbody()
                ).withId("ratingTable").withClass("stripe").withStyle("min-width: 480px;"),
                h2("List of games").attr("align", "center"),
                div(
                        img().withSrc("/images/loader.gif").attr("width", 60).attr("heigh", 60)
                ).withId("gamesChart").withClass("gchart")
        );