Skip to content

Commit c75c155

Browse files
authored
Merge pull request #175 from Suzu-Gears/fix-Codepen-aspect-ratio
Add CodePen embed aspect-ratio
2 parents 5726b1c + d41e69c commit c75c155

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/components/notion-blocks/CodePenEmbed.astro

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,22 @@ const user = url.pathname.split('/')[1]
77
const id = url.pathname.split('/')[3]
88
---
99

10-
<div class="codepen-embed">
11-
<p
12-
class="codepen"
13-
data-height="500"
14-
data-slug-hash={id.toString()}
15-
data-user={user.toString()}
16-
style="height: 300px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;"
17-
>
18-
</p>
19-
</div>
10+
<p
11+
class="codepen"
12+
data-slug-hash={id.toString()}
13+
data-user={user.toString()}
14+
style="box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;"
15+
>
16+
</p>
2017
<script async src="https://cpwebassets.codepen.io/assets/embed/ei.js"></script>
2118

22-
<style>
23-
.codepen-embed {
19+
<style is:global>
20+
.cp_embed_wrapper {
21+
width: 100%;
22+
aspect-ratio: 1.6 / 1;
2423
background-color: #fff;
2524
}
25+
.cp_embed_wrapper iframe {
26+
height: 100% !important;
27+
}
2628
</style>

0 commit comments

Comments
 (0)