gpt4 book ai didi

css - 如何在 `border-radius` 中设置 `paper-listbox` 的 `paper-dropdown-menu`?

转载 作者:太空宇宙 更新时间:2023-11-04 01:09:40 25 4
gpt4 key购买 nike

我正在尝试圆化 paper-listbox 的 Angular ,它包含在 paper-dropdown-menu 中。但是,以下 CSS 并没有像我预期的那样改变边框半径:

paper-listbox {
border-radius: 14pt !important;
--paper-listbox: {
border-radius: 14pt;
overflow: hidden;
};
}

如何设置paper-listboxborder-radius

屏幕截图:

screenshot

最佳答案

<paper-dropdown-menu> 的内部 DOM看起来像这样:

  <paper-menu-button>
<iron-dropdown>
<div slot="dropdown-content" class="dropdown-content">
<slot name="dropdown-content"></slot> <!-- user's slot content of paper-dropdown-menu is inserted here -->
</div>
</iron-dropdown>
</paper-menu-button>

所以这个用户代码:

<paper-dropdown-menu>
<paper-listbox slot="dropdown-content"> <!-- user's slot content -->
</paper-listbox>
</paper-dropdown-menu>

变成:

<paper-dropdown-menu>
<paper-menu-button>
<iron-dropdown>
<div slot="dropdown-content" class="dropdown-content">
<paper-listbox> <!-- user's slot content inserted -->
</paper-listbox>
</div>
</iron-dropdown>
</paper-menu-button>
</paper-dropdown-menu>

<paper-menu-button> , div.dropdown-content 容器是 styled显示框阴影(通过 --shadow-elevation-2dp ),使 <div> 的方形边缘出现。您用来设置 <paper-listbox> 样式的 CSS确实设置了列表框的样式,但您看到的方形边缘实际上来自列表框的父项 ( div.dropdown-content ) 及其框阴影边缘。您可以覆盖 div.dropdown-content 的样式与 --paper-menu-button-content mixin,步骤如下:

  1. 为您的 <paper-dropdown-menu> 应用一个类:

    <paper-dropdown-menu class="dropdown">
  2. 为设置 --paper-menu-button-content 的类创建样式:

    <style>
    .dropdown {
    --paper-menu-button-content: {
    border-radius: 14pt;
    }
    }
    </style>

window.addEventListener('WebComponentsReady', () => {
class XFoo extends Polymer.Element {
static get is() { return 'x-foo'; }

static get properties() {
return {
customers: {
type: Array,
value: () => [
'Alice',
'Bob',
'Charlie',
'David',
]
}
};
}
}
customElements.define(XFoo.is, XFoo);
});
<head>
<base href="https://cdn.rawgit.com/download/polymer-cdn/2.6.0.2/lib/">
<script src="webcomponentsjs/webcomponents-loader.js"></script>
<link rel="import" href="polymer/polymer.html">
<link rel="import" href="paper-listbox/paper-listbox.html">
<link rel="import" href="paper-item/paper-item.html">
<link rel="import" href="paper-dropdown-menu/paper-dropdown-menu.html">
<link rel="import" href="neon-animation/web-animations.html">
</head>
<body>
<x-foo></x-foo>

<dom-module id="x-foo">
<template>
<style>
.dropdown {
--paper-menu-button-content: {
border-radius: 14pt;
}
}
</style>

<paper-dropdown-menu id="customer"
class="dropdown"
placeholder="Select Customer">
<paper-listbox id="customerList"
slot="dropdown-content"
attr-for-selected="value"
selected="[[customer]]">
<template is="dom-repeat" items="[[customers]]" as="customer">
<paper-item value="[[customer]]">[[customer]]</paper-item>
</template>
</paper-listbox>
</paper-dropdown-menu>
</template>
</dom-module>
</body>

关于css - 如何在 `border-radius` 中设置 `paper-listbox` 的 `paper-dropdown-menu`?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51449614/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com