html - 为什么另一个客户元素的阴影根中的阴影元素的百分比宽度和高度不起作用?
问题描述
HTML:
<options-container>
<options-panel panel-type=“login”></options-panel>
</options-container>
父自定义元素样式:
options-container {
display: inline-flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
height: calc(100vh - 52px);
height: calc(100vh - (45px + 0.3vw));
min-height: max(calc(56.25vw - 52px), calc(100vh - 52px));
min-height: max(calc(56.25vw - (45px + 0.3vw)), calc(100vh - (45px + 0.3vw)));
position: fixed;
top: 52px;
top: calc(45px + 0.3vw);
right: 0;
z-index: 1;
width: calc(300px + 3vw);
-webkit-backface-visibility: hidden;
-webkit-perspective: 1000;
-webkit-transform-style: preserve-3d;
-webkit-transition: width 0.5s ease-in-out;
-moz-transition: width 0.5s ease-in-out;
-o-transition: width 0.5s ease-in-out;
transition: width 0.5s ease-in-out;
will-change: width;
pointer-events: none;
}
子元素(在上述元素的阴影根中)样式:
:host {
display: inline-flex;
justify-content: flex-start;
align-items: center;
flex-direction: column;
width: 90%;
height: auto;
max-height: 100vh;
padding: 10px;
min-height: 10vw;
background-color: var(--white, white);
border: 2px solid var(--light-gray, lightgray);
border: 0.2vw solid var(--light-gray, lightgray);
box-sizing: border-box;
margin-top: 20px;
border-radius: 10px;
border-radius: calc(8px + 0.3vw);
overflow: hidden;
box-shadow: 0px 0px 10px 0px var(--shadow, black);
box-shadow: 0px 0px calc(8px + 0.3vw) 0px var(--shadow, black);
pointer-events: auto;
animation: fly-down 1.5s ease-out;
animation-play-state: running;
-webkit-transform: translate3d(0, 0, 0) !important;
-webkit-backface-visibility: hidden;
-webkit-transform-style: preserve-3d;
-webkit-transition: max-height 0.5s ease-in-out 0.5s;
-moz-transition: max-height 0.5s ease-in-out 0.5s;
-o-transition: max-height 0.5s ease-in-out 0.5s;
transition: max-height 0.5s ease-in-out 0.5s;
will-change: max-height;
}
父元素框模型
子元素盒模型
在试图解释这种行为时遇到了真正的麻烦,而试图让子元素变得可见则更加困难。我可能错过了一些非常小的东西,我不知道。但任何指导和/或解释将不胜感激!
解决方案
找到答案了!
令人尴尬的菜鸟错误,我在元素上附加了一个阴影根<options-container>
,这就是子元素没有被渲染的原因。根本与 CSS 无关。
类似情况的自己和其他人注意:检查影子根。
正在做
this.shadowroot = this.attachShadow({mode: 'open'});
是答案。
推荐阅读
- angular - 如何在 Angular 5 中执行缓存 http get 请求?
- node.js - 如何让多个用户使用单一路由登录
- dialogflow-es - Dialogflow v2 Beta 1 使用 Python 更新意图
- java - TableRow 在 TableLayout 中返回空值?
- sql - SQL 乘以 AVG
- java - 下拉单击时 Android Webview 崩溃
- image-processing - Keras ImageDataGenerator 将值重新缩放为 [-0.5, 0.5]
- python - project euler #4 使用 python 的最大回文
- javascript - 如何使用单个键盘快捷键复制和粘贴 Electron 中的文本?
- javascript - 导入到 vue.js 组件中