设置倾斜 <section> 的边距

Fab*_*Zbi 5 html css skew css-transforms

我只是倾斜了用作横幅的部分。

现在,由于倾斜,该部分的高度明显高于预期。

如何根据这个新高度定义底部边距?

.banner{
    transform: skewY(-5deg);
    transform-origin: top right;
    outline: solid 1px black;
    margin-bottom: 5rem;
}
Run Code Online (Sandbox Code Playgroud)
<section class="banner">
  <h1>Hello World!</h1>
  <h2>Subtitle</h2>
</section>
<div class="content">
  <p>CONTENT</p>
</div>
Run Code Online (Sandbox Code Playgroud)

如果您以全屏方式打开代码片段并更改窗口大小,您就会知道我的意思...内容只是隐藏在横幅后面。

提前致谢!

Pra*_*lan 2

实际上,大小是根据宽度而变化的,因此根据宽度更新边距,为此您可以使用unitvw

.banner{
    transform: skewY(-5deg);
    transform-origin: top right;
    outline: solid 1px black;
    margin-bottom: 9vw;
}
Run Code Online (Sandbox Code Playgroud)
<section class="banner">
  <h1>Hello World!</h1>
  <h2>Subtitle</h2>
</section>
<div class="content">
  <p>CONTENT</p>
</div>
Run Code Online (Sandbox Code Playgroud)