在 Windows 8 的 WinJS 应用程序中,您可以使用 -ms-grid 和 -ms-flexbox 来实现此目的。
html:
<div class="mypage fragment">
<header aria-label="Header content" role="banner">
<button class="win-backbutton" aria-label="Back" disabled type="button"></button>
<h1 class="titlearea win-type-ellipsis">
<span class="pagetitle">My Page</span>
</h1>
</header>
<section role="main">
<canvas id="myCanvas">
</canvas>
<div class="ad-area-host">
<div class="ad-area" style="width: 728px; height: 90px; border: solid 1px red; visibility:visible;"
data-win-control="MicrosoftNSJS.Advertising.AdControl"
data-win-options="{applicationId: 'xyz', adUnitId: '123'}">
</div>
</div>
</section>
</div>
CSS:
// some of the css for fragment and section[role=main] already exists in default.css
.fragment
{
width: 100%;
height: 100%;
/* Define a grid with rows for a banner and a body */
-ms-grid-columns: 1fr;
-ms-grid-rows: 128px 1fr;
display: -ms-grid;
}
.mypage.fragment section[role=main]
{
-ms-grid-row: 2;
display: -ms-grid;
-ms-grid-rows: 1fr auto;
-ms-grid-columns: 1fr;
}
.ad-area-host
{
-ms-grid-row: 2;
height: 90px;
display: -ms-flexbox;
-ms-flex-direction: column;
-ms-flex-align: center;
}
我没有测试过这个。试试看。这个想法是使用网格在底部对齐广告区域主机。然后,在 ad-area-host div 中使用 -ms-flexbox display 使广告区域居中。