Как сделать такую фигуру на CSS и HTML?
2 ответа
body {
margin: 0;
padding: 0;
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100vh;
min-height: 300px;
}
.block {
position: relative;
width: 250px;
height: 50px;
background-color: rgba(104, 144, 231, 1);
}
.block:before {
position: absolute;
content: '';
top: 0;
left: -50px;
width: 0;
height: 0;
border-top: 50px solid rgba(104, 144, 231, 1);
border-left: 50px solid transparent;
}
.block:after {
position: absolute;
content: '';
top: 0;
right: -50px;
width: 0;
height: 0;
border-top: 50px solid rgba(104, 144, 231, 1);
border-right: 50px solid transparent;
}
<div class="block"></div>
Подробнее про геометрические фигуры на CSS
Про псевдоэлементы :before, :after
Про FlexBox: на русском и английском
Смотря для чего нужна эта фигура, возможен еще такой вариант:
.shape {
width: 240px;
height: 40px;
background: #6890E7;
margin: auto;
transform: perspective(120px) rotateX(-45deg);
}
<div class="shape"></div>