对于我的生活,当我在顶部有一个应用工具栏时,我似乎无法从此paper-dialog
的顶部删除愚蠢的边距。
我设法使用div
只使用标准margin-top: 0px;
对其进行排序,但我无法对app-toolbar
执行相同操作。
Chrome上的开发者模式的罪魁祸首似乎是这一行,但我无法实现......
代码
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;
答案 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!