[英]How to center GWT html page?
I tried to center my GWT html page with the following css 我尝试使用以下CSS将GWT html页面居中
body {
color:#000000;
font:1px Impact;
text-align:center;
width:1000px;
margin:auto;
}
I also tried several different kinds for margin like 我也尝试了几种不同的保证金
margin: 1px auto;
or 要么
margin: 1% auto;
The page shows up in the middle for a short time, then switches to the left side. 该页面会在中间显示一小段时间,然后切换到左侧。 I got the code working outside GWT. 我让代码在GWT之外工作。
What is the problem? 问题是什么?
Add a new
div
in your HTML/JSP file that iscenter
algined and now add your root component in thatdiv
. 在HTML / JSP文件中添加一个center
设置的新div
,然后在该div
添加根组件。
Entry Point class: 入口点类别:
public class GWTProject implements EntryPoint {
public void onModuleLoad() {
RootPanel.get("container").add(initComponent);
}
}
HTML/JSP: HTML / JSP:
...
<body>
<div id="container" align="center"></div>
</body>
...
Its as simple as it is. 它是如此简单。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.