Другой метод для достижения того же решения - использование pseudo:after
, как показано в приведенном ниже рабочем примере, надеюсь, это поможет:)
.box {
margin: 150px;
width: 250px;
height: 250px;
background: linear-gradient(to right, #3acfd5 0%, #3a4ed5 100%);
transform: rotate(45deg);
display: flex;
align-items: center;
justify-content: center;
position: relative;
}
.box:after {
left: 20px;
right: 20px;
top: 20px;
bottom: 20px;
content: '';
background: lightGray;
position: absolute;
}
.r45 {
transform: rotate(-45deg);
color: red;
position: relative;
z-index: 1;
}
<div class="box">
<p class="r45">Hello</p>
</div>