只需將iframe
內的div
即center
對齊。
試試這個
public void onModuleLoad() {
// Make a new frame, and point it at Google.
Frame frame = new Frame("http://www.google.com/");
// Add it to the root panel.
RootPanel.get("container").add(frame);
}
JSP/HTML:
...
<body>
<div id="container" align="center"></div>
</body>
...
或嘗試這是與上面相同,但div
在Java代碼中創建
// Make a new frame, and point it at Google.
Frame frame = new Frame("http://www.google.com/");
DivElement div = Document.get().createDivElement();
div.setAttribute("align", "center");
div.appendChild(frame.getElement());
// Add it to the root panel.
RootPanel.get().getElement().appendChild(div);
顯示一些代碼。你在說什麼? – Braj
@Braj我正在使用com.google.gwt.user.client.ui.Frame; –
我已經發布了一個答案。請看一看。 – Braj