如何在 Polymer 1.0 中更改纸张输入的字体大小

How to change font-size of paper-input in Polymer 1.0

在 Polymer 1.0 中,我可以轻松更改 iron-input 组件的字体大小,例如:

input {
   font-size: 24px;
}

如果我在纸张输入容器中使用熨斗输入组件,则它不起作用。如果我只使用纸张输入组件,它也不能正常工作。你是怎么做到的?提前致谢。

您可以使用 --paper-input-container-input 混入来做到这一点。您可以在自己的元素上或通过 <style is="custom-style"> 使用它。也不要忘记每次混合后的分号。

我允许自己详细说明正确答案,因为我无法理解 mixin 概念的工作原理以及如何应用可用于许多其他事情的解决方案(更改其他属性,如字体、样式..).如果我的元素中有以下纸张输入的解决方案

<paper-input id="title" label="Note title"></paper-input>

就是在我的元素中有如下样式

<style>
  #title {
    --paper-input-container-input: {
      font-size: 24px;
    };
  }
</style>

我还可以在导入的 html 文件中全局定义样式

<style is="custom-style">
  :root {
    --paper-input-container-input: {
      font-size: 24px;
    };
  }
</style>