<div id="description">
<h2>Приклад 1</h2>
<p>Малювання паралелограмів за допомогою функції tan()</p>
</div>
<div id="result">
<div class="parallelogram"></div>
</div>
#description {
font-style: italic;
text-align: left;
line-height: 1.5;
margin-bottom: 50px;
padding: 12px 16px;
background-color: #f7f7f7;
border: 1px solid #ccc;
}
#result {
display: flex;
justify-content: center;
align-items: center;
height: 200px;
}
.parallelogram {
--w: 400;
--h: 200;
--angle: 30deg;
position: relative;
width: calc(1px * var(--w));
height: calc(1px * var(--h));
}
.parallelogram::before {
content: "";
position: absolute;
width: calc(100% - 100% * var(--h) / var(--w) * tan(var(--angle)));
height: 100%;
transform-origin: 0 100%;
transform: skewX(calc(0deg - var(--angle)));
background-color: red;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.