影像與文字 (集合) 範本 (HTML)
[ 本文的目標對象是撰寫 Windows 執行階段 App 的 Windows 8.x 和 Windows Phone 8.x 開發人員。如果您正在開發適用於 Windows 10 的 App,請參閱 最新文件 ]
定義包含影像、大標題、次標題及內文的項目。 這個範本用來與具備格線配置的 ListView 搭配使用。如需其他的範本,請參閱格線配置的項目範本以及清單配置的項目範本。
使用範本
如果要使用範本,請將 HTML 和 CSS 樣式複製到您的專案。HTML 有一個專門設計用來與範本搭配使用的 ListView。複製 HTML 之後,請將 ListView 控制項的 itemDataSource 設定成應用程式的資料來源,然後更新範本的 data-win-bind 屬性,讓它們可以處理您的資料。
若要讓範本正常運作,將 win-selectionstylefilled
類別指派到您的 ListView。
HTML
<!-- Item template -->
<div id="imageTextCollectionTemplate"
data-win-control="WinJS.Binding.Template">
<div class="imageTextCollection">
<img class="imageTextCollectionImage"
data-win-bind="src: icon" />
<div class="imageTextCollectionDetail">
<h3 class="imageTextCollectionTextStrong"
data-win-bind="innerText: largeText">
</h3>
<h6 class="imageTextCollectionTextLight"
data-win-bind="innerText: smallText">
</h6>
<div class="imageTextCollectionText"
data-win-bind="innerText: mediumText">
</div>
</div>
</div>
</div>
<!-- ListView -->
<div id="imageTextCollection" class="win-selectionstylefilled"
data-win-control="WinJS.UI.ListView"
data-win-options="{ itemDataSource: list.dataSource,
itemTemplate: select('#imageTextCollectionTemplate'),
layout: { type: WinJS.UI.GridLayout } }">
</div>
CSS
/* overall list dimensions */
#imageTextCollection {
width: 1366px;
height: 578px;
}
/*-------------------------------------------------------------------------------------------*/
/* imageText-collection - used app template collection page */
/*-------------------------------------------------------------------------------------------*/
/* style the background color of the filled-selection style items */
.win-selectionstylefilled :not(.win-footprint).win-container {
background-color: transparent;
}
.win-selectionstylefilled .win-container.win-swipe:hover {
background-color: transparent;
}
/* starting margin */
#imageTextCollection .win-horizontal.win-viewport .win-surface {
margin: 0px 80px;
}
/* margin between items */
#imageTextCollection .win-horizontal.win-viewport .win-container {
margin: 5px 30px;
}
/* individual item dimensions */
.imageTextCollection {
width: 490px;
height: 120px;
padding: 5px;
overflow: hidden;
display: -ms-grid;
}
/* image */
.imageTextCollection img.imageTextCollectionImage {
margin: 5px;
width: 110px;
height: 110px;
-ms-grid-column: 1;
}
.imageTextCollection .imageTextCollectionDetail {
margin: 9px 5px 5px 5px;
-ms-grid-column: 2;
}
/* text line 1 */
.imageTextCollection .imageTextCollectionDetail .imageTextCollectionTextStrong {
width: 360px;
height: 20px;
white-space: nowrap;
}
/* text line 2 */
.imageTextCollection .imageTextCollectionDetail .imageTextCollectionTextLight {
width: 360px;
height: 20px;
overflow: hidden;
}
/* text line 3 */
.imageTextCollection .imageTextCollectionDetail .imageTextCollectionText {
width: 360px;
height: 60px;
overflow: hidden;
}