Fixed dimension for cordova app

北战南征 提交于 2019-12-01 12:27:27

Assuming your HTML area is in one nice div container - set its position to "absolute" and then use javascript to explicitly set its X position with xpos = (screenWidth - htmlWidth)/2

You can try to use a container like this:

.container {
  background: red;
  height: 400px;
  width: 600px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}
<div class="container">
  <h1>
    hello
  </h1>
</div>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!