Such an apparently simple thing...and yet it turns out to be very hard to do. You'll find a lot of people struggling with it if you search on subjects like this:
http://www.google.com/search?q=html+vertical+alignment I needed to be able to vertically align text on my GWT button widgets; I ended tweaking the CSS like this: /* GWT sets the content of a CustomButton (PushButton or ToggleButton) as: * <div style="html-face"> user-specified-content </div> * If we define that <div> to be a table, then we can set the user content * as an internal <div> with a style of table-cell, which can be vertically * aligned. */ .html-face { display: table; height: 100%; margin: auto; } Then I override setText() and setHTML() to do something like this: public void setText(String text) { alignText(text); } public void setHTML(String html) { alignText(html); } private void alignText(String text) { StringBuilder html = new StringBuilder("<html>"); html.append("<div style=\"display: table-cell; "); html.append("vertical-align: middle; "); html.append("text-align: center; "); html.append("overflow: hidden; text-overflow: ellipsis;\">"); if (text.toLowerCase().startsWith("<html>")) { html.append(text.substring("<html>".length())); } else { html.append(text); } html.append("</div></html>"); text = html.toString(); super.setHTML(text); } On Dec 18, 4:00 pm, "[email protected]" <[email protected]> wrote: > What's a simple workaround? > > Amir -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
