Fixed dimension for cordova app

前端 未结 2 481
傲寒
傲寒 2021-01-15 22:05

I am trying to create a cordova application with a fixed width and height.If the device width is higher than the application width then it will display inside of the device

相关标签:
2条回答
  • 2021-01-15 22:45

    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

    0 讨论(0)
  • 2021-01-15 22:47

    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>

    0 讨论(0)
提交回复
热议问题