amp基本转盘脱离父级,布局=填充



我正在尝试使用flex布局来显示一个元素,并允许其余元素根据可用空间增长。

我使用以下标记和样式来实现这一点。

<!doctype html>
<html ⚡>
<head>
<meta charset="utf-8">
<title>My AMP Page</title>
<link rel="canonical" href="self.html" />
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-base-carousel" src="https://cdn.ampproject.org/v0/amp-base-carousel-0.1.js"></script>
<style amp-custom>
.bodywrapper {
display: flex;
flex-direction: column;
background-color: lightseagreen;
height: 100vh;
}
h1 {
flex: 0 1 auto;
background-color: green;
}
div.wrapper {
background-color: lightcoral;
flex: 1 0 auto;
}
.scrollable {
overflow-y: auto;
}
</style>
</head>
<body>
<div class="bodywrapper">
<h1>Hello AMPHTML World!</h1>
<div class="wrapper">
<amp-base-carousel [slide]="selectedSlide" on="slideChange:AMP.setState({selectedSlide:event.index})" id="imageSlides" mixed-length="true" layout="fill">
<div class="scrollable">
Exercitation excepteur culpa nostrud consequat consectetur in deserunt.
</div>
<div class="scrollable">
Contrary to popular belief, Lorem Ipsum is not simply random text.
</div>
</amp-base-carousel>
</div>
</div>
</body>
</html>

(请忽略此示例中未实现放大器状态。(

但是,amp-base-carousel内容脱离父容器(".wapper"(,显示在h1后面。

这与基本转盘无关,而是与AMP的fill布局有关,后者需要容器设置position: relative

最新更新