Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a box with a "dynamic height"

I am looking for a way to create a div with CSS that looks like this graphic:

enter image description here

The bottom on the right is not white but transparent.

How would that be possible?

like image 480
Reza Avatar asked Dec 02 '25 09:12

Reza


1 Answers

Method #01:

Use transformed pseudo element i.e :before or :after.

body {
  background: #ccc;
}

div {
  position: relative;
  overflow: hidden;
  height: 100px;
}

div:before {
  transform: rotate(-3deg);
  position: absolute;
  background: brown;
  height: 100%;
  bottom: 40%;
  content: '';
  right: -50px;
  left: -50px;
}
<div></div>

Method #02:

Use css3 linear-gradient.

background: linear-gradient(175deg, brown 60%, transparent 60%);

div {
  background: linear-gradient(175deg, brown 60%, transparent 60%);
  height: 100px;
}
<div></div>
like image 172
Mohammad Usman Avatar answered Dec 04 '25 01:12

Mohammad Usman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!