我正试图设定gold-email-input
的高度。我尝试用以下方式设置高度:
gold-email-input {
background-color: var(--light-theme-base-color);
width: 100%;
height: 48px;
max-width: 670px;
padding: 0px;
--paper-input-container: {
max-height: 48px;
};
}
但是当paper-input-container
调整为48px时,我会尝试61px
停留gold-email-input
。我能做些什么来解决这个问题吗?
答案 0 :(得分:1)
如果您希望paper-input-container
的高度与gold-email-input
的高度相匹配,您可以将其height
设置为100%
,并清除其margin
和padding
:
gold-email-input {
--paper-input-container: {
height: 100%;
margin: 0;
padding: 0;
}
}
要设置自定义元素之外的gold-email-input
样式,请务必使用custom-style
:
<head>
<base href="https://polygit.org/polymer+1.4.0/components/">
<script src="webcomponentsjs/webcomponents-lite.min.js"></script>
<link rel="import" href="gold-email-input/gold-email-input.html">
</head>
<body>
<style is="custom-style">
:root {
--light-theme-base-color: rgba(0,112,0,0.4);
}
gold-email-input {
background-color: var(--light-theme-base-color);
width: 100%;
height: 248px;
max-width: 670px;
padding: 0px;
--paper-input-container: {
outline: solid 3px red;
height: 100%;
margin: 0;
padding: 0;
};
}
</style>
<gold-email-input></gold-email-input>
</body>
在自定义元素中,您可以在custom-style
内正常使用该样式(即没有dom-module
):
<head>
<base href="https://polygit.org/polymer+1.4.0/components/">
<script src="webcomponentsjs/webcomponents-lite.min.js"></script>
<link rel="import" href="gold-email-input/gold-email-input.html">
</head>
<body>
<style is="custom-style">
:root {
--light-theme-base-color: rgba(0,112,0,0.4);
}
</style>
<x-foo></x-foo>
<dom-module id="x-foo">
<style>
gold-email-input {
background-color: var(--light-theme-base-color);
width: 100%;
height: 248px;
max-width: 670px;
padding: 0px;
--paper-input-container: {
outline: solid 3px red;
height: 100%;
margin: 0;
padding: 0;
};
}
</style>
<template>
<gold-email-input></gold-email-input>
</template>
<script>
HTMLImports.whenReady(function() {
Polymer({
is: 'x-foo'
});
});
</script>
</dom-module>
</body>