是否可以在 Polymer 纸制品中设置 html 样式?
Is styled html in a Polymer paper-item possible?
我正在尝试将一些丰富的内容放入 paper-menu
的项目中,但这似乎无法按预期工作(请参见下面的屏幕截图)。
将样式 html 添加到 paper-item
需要做什么。
代码在这里:
<style is="custom-style">
.personItem {
@apply(--layout-horizontal);
margin: 16px 16px 0 16px;
padding: 20px;
border-radius: 8px;
background-color: white;
border: 1px solid #ddd;
}
.avatar {
height: 50px;
width: 50px;
border-radius: 25px;
box-sizing: border-box;
background-color: #DDD;
}
.pad {
padding: 0 16px;
@apply(--layout-flex);
@apply(--layout-vertical);
}
.primary {
font-size: 16px;
font-weight: bold;
}
.dim {
color: gray;
}
</style>
<paper-menu-button vertical-align="top" horizontal-align="right" vertical-offset="64">
<paper-icon-button id="notif" icon="social:notifications" class="dropdown-trigger" alt="menu"></paper-icon-button>
<paper-menu class="dropdown-content">
<template is="dom-repeat" items="[[notifications]]" as="item">
<paper-item>
<paper-item-body two-line>
<!--<div th:inline="none"><iron-icon icon='communication:message'></iron-icon></div>-->
<div secondary th:inline="none">
<div class="personItem">
<iron-image class="avatar" sizing="contain" src="[[item.pic]]"></iron-image>
<div class="pad">
<div class="primary" th:inline="none">
<span style="float:right;">[[m.date]]</span>
<span>[[m.user]]</span>
</div>
<div class="dim" th:inline="none">[[m.content]]</div>
</div>
</div>
</div>
</paper-item-body>
</paper-item>
</template>
</paper-menu>
</paper-menu-button>
<paper-badge id="badge" for="notif" label="[[number]]"></paper-badge>
这或多或少产生了我想要达到的效果:
<paper-menu-button>
<paper-icon-button id="n" icon="social:notifications" class="dropdown-trigger" alt="menu"></paper-icon-button>
<paper-menu class="dropdown-content">
<template is="dom-repeat" items="[[notifications]]" as="item">
<paper-icon-item>
<iron-icon item-icon class="avatar" sizing="contain" src="/path/to/pic"></iron-icon>
<paper-item-body two-line>
<div>John Doe</div>
<div secondary>Hello World</div>
</paper-item-body>
<paper-icon-button icon="communication:message"></paper-icon-button>
</paper-icon-item>
</template>
</paper-menu>
</paper-menu-button>
<paper-badge id="badge" for="n" label="[[number]]"></paper-badge>
我正在尝试将一些丰富的内容放入 paper-menu
的项目中,但这似乎无法按预期工作(请参见下面的屏幕截图)。
将样式 html 添加到 paper-item
需要做什么。
代码在这里:
<style is="custom-style">
.personItem {
@apply(--layout-horizontal);
margin: 16px 16px 0 16px;
padding: 20px;
border-radius: 8px;
background-color: white;
border: 1px solid #ddd;
}
.avatar {
height: 50px;
width: 50px;
border-radius: 25px;
box-sizing: border-box;
background-color: #DDD;
}
.pad {
padding: 0 16px;
@apply(--layout-flex);
@apply(--layout-vertical);
}
.primary {
font-size: 16px;
font-weight: bold;
}
.dim {
color: gray;
}
</style>
<paper-menu-button vertical-align="top" horizontal-align="right" vertical-offset="64">
<paper-icon-button id="notif" icon="social:notifications" class="dropdown-trigger" alt="menu"></paper-icon-button>
<paper-menu class="dropdown-content">
<template is="dom-repeat" items="[[notifications]]" as="item">
<paper-item>
<paper-item-body two-line>
<!--<div th:inline="none"><iron-icon icon='communication:message'></iron-icon></div>-->
<div secondary th:inline="none">
<div class="personItem">
<iron-image class="avatar" sizing="contain" src="[[item.pic]]"></iron-image>
<div class="pad">
<div class="primary" th:inline="none">
<span style="float:right;">[[m.date]]</span>
<span>[[m.user]]</span>
</div>
<div class="dim" th:inline="none">[[m.content]]</div>
</div>
</div>
</div>
</paper-item-body>
</paper-item>
</template>
</paper-menu>
</paper-menu-button>
<paper-badge id="badge" for="notif" label="[[number]]"></paper-badge>
这或多或少产生了我想要达到的效果:
<paper-menu-button>
<paper-icon-button id="n" icon="social:notifications" class="dropdown-trigger" alt="menu"></paper-icon-button>
<paper-menu class="dropdown-content">
<template is="dom-repeat" items="[[notifications]]" as="item">
<paper-icon-item>
<iron-icon item-icon class="avatar" sizing="contain" src="/path/to/pic"></iron-icon>
<paper-item-body two-line>
<div>John Doe</div>
<div secondary>Hello World</div>
</paper-item-body>
<paper-icon-button icon="communication:message"></paper-icon-button>
</paper-icon-item>
</template>
</paper-menu>
</paper-menu-button>
<paper-badge id="badge" for="n" label="[[number]]"></paper-badge>