【发布时间】:2020-06-05 23:57:11
【问题描述】:
我正在尝试将基于图像的信息图形转换为 html 和 css。我可以在那里得到 90%,但我正在寻找一些关于折叠色带效果的帮助。 信息图有这样的是/否方向:
“丝带”的末端折叠在下面,并以较深的原色阴影突出底部。
这是我目前所拥有的:
<style>
.container { display: flex; flex-wrap: wrap; background-color: white; border-radius: 1em; }
.container .header { width: 100%; font-size: 3em; font-weight: bold; line-height: 0.9; padding: 1em 3em !important; text-align: center }
.container .child:first-child { width: 100%; }
.container .child:not(:first-child) { width: 50%; font-size: 13px; }
.container .child { display: inline-block; padding: 1em; }
.container .leftcol { border-right: 2px solid black; }
.container .redright { position: relative; background-color: #cd1719; color: white; font-size: 3em; font-weight: bold; padding-left: 0.5em; border-radius: 0.25em; margin-bottom: 0.5em; }
.container .greenleft { position: relative; background-color: #7fbc03; color: white; text-align: right; font-size: 3em; font-weight: bold; padding-right: 0.5em; border-radius: 0.25em; margin-bottom: 0.5em; }
.container .greenleft::before { content: ""; position: absolute; top: 0; left: 0; border-width: 1.5em 1em 1.25em 0; border-color: white #7fbc03 transparent transparent; display: block; border-style: solid; bottom: -1em; }
</style>
<div class="container">
<div class="child header">Header</div>
<div class="child leftcol">
<div class="greenleft">Yes</div>
<p>Content on the left</p>
</div>
<div class="child rightcol">
<div class="redright">No</div>
<p>Content on the right</p>
</div>
</div>
【问题讨论】:
-
嗨,欢迎来到 SO!我相信这个Codepen 的代码会帮助你。
-
谢谢@Rene,这很接近,但三角形最终是一条垂直线 - 如果可能的话,我想要更接近等边三角形的东西。
标签: html css css-shapes