在纸对话框 - 聚合物中删除应用工具栏中的顶部填充

时间:2017-07-10 13:57:57

标签: html css polymer paper-dialog

对于我的生活,当我在顶部有一个应用工具栏时,我似乎无法从此paper-dialog的顶部删除愚蠢的边距。

我设法使用div只使用标准margin-top: 0px;对其进行排序,但我无法对app-toolbar执行相同操作。

enter image description here

Chrome上的开发者模式的罪魁祸首似乎是这一行,但我无法实现......

enter image description here

代码



paper-dialog {
  border-radius: 2px;
}

app-toolbar {
  background: green;
  margin-top: 0px;
}

.card-content {
  margin-top: 0px;
}

<base href="https://polygit.org/polymer+polymer+v1.9.1/components/" />
<script src="webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="polymer/polymer.html" />
<link rel="import" href="paper-dialog/paper-dialog.html" />
<link rel="import" href="app-layout/app-toolbar/app-toolbar.html" />
<link rel="import" href="paper-input/paper-input.html" />
<link rel="import" href="neon-animation/animations/scale-up-animation.html" />

<paper-dialog modal alwaysOnTop opened horizontalAlign="auto" entry-animation="scale-up-animation" exit-animation="fade-out-animation">
  <app-toolbar>Log in</app-toolbar>
  <div class="card-content">
    <paper-input placeholder="username or email"></paper-input>
    <paper-input placeholder="password"></paper-input>
  </div>
</paper-dialog>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:2)

让CSS替换继承的CSS的诀窍比继承的CSS更具体。

为了做到这一点,我在纸质对话框中添加了一个类,然后为选择器我说paper-dialog.someclass>app-toolbar:first-child,这意味着应用工具栏的第一个实例是纸质对话框,类为someclass。

然后接受这个CSS覆盖继承的位。

paper-dialog {
  border-radius: 2px;
}

paper-dialog.someclass>app-toolbar:first-child {
  background: green;
  margin-top: 0px;
}

.card-content {
  margin-top: 0px;
}
<base href="https://polygit.org/polymer+polymer+v1.9.1/components/" />
<script src="webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="polymer/polymer.html" />
<link rel="import" href="paper-dialog/paper-dialog.html" />
<link rel="import" href="app-layout/app-toolbar/app-toolbar.html" />
<link rel="import" href="paper-input/paper-input.html" />
<link rel="import" href="neon-animation/animations/scale-up-animation.html" />

<paper-dialog class="someclass" modal alwaysOnTop opened horizontalAlign="auto" entry-animation="scale-up-animation" exit-animation="fade-out-animation">
  <app-toolbar>Log in</app-toolbar>
  <div class="card-content">
    <paper-input placeholder="username or email"></paper-input>
    <paper-input placeholder="password"></paper-input>
  </div>
</paper-dialog>

答案 1 :(得分:2)

尝试添加:

padding-top: 0px;
margin-top: 0px;

你的css用于纸张对话框或包含纸张对话框的div!