Using CSS Gradients + Transforms:
One way to achieve this shape with the response at the top is to use two skewed pseudo-elements, adding a background only to the pseudo-elements, and not to the parent element.
, linear-gradient, , 2 .
, , div .
.shape {
position: relative;
height: 100px;
width: 100%;
overflow: hidden;
}
.shape:after,
.shape:before {
position: absolute;
content: '';
height: 100%;
width: calc(50% + 1px);
top: 0;
backface-visibility: hidden;
}
.shape:before {
left: 0;
background-image: linear-gradient(to right, red, gold);
transform: skewY(2deg);
transform-origin: left top;
}
.shape:after {
right: 0;
background-image: linear-gradient(to right, gold, crimson);
transform: skewY(-2deg);
transform-origin: right top;
}
body {
background-image: radial-gradient(circle at center, sandybrown, chocolate);
min-height: 100vh;
}
<div class='shape'></div>
Hide resultCSS Clip-path: ( )
CSS clip-path. , , , (, ), , div .. , , .
.shape {
height: 100px;
width: 100%;
-webkit-clip-path: polygon(0px 0px, 50% 14px, 100% 0%, 100% 100%, 0% 100%);
background-image: linear-gradient(to right, red, gold, crimson);
}
body {
background-image: radial-gradient(circle at center, sandybrown, chocolate);
min-height: 100vh;
}
<div class='shape'></div>
Hide resultSVG Clip-path: ( )
SVG clip-path. , CSS, , , .
.shape {
height: 100px;
width: 100%;
-webkit-clip-path: url(#clipper);
clip-path: url(#clipper);
background-image: linear-gradient(to right, red, gold, crimson);
}
body {
background-image: radial-gradient(circle at center, sandybrown, chocolate);
min-height: 100vh;
}
<svg width="0" height="0" viewBox="0 0 200 200">
<defs>
<clipPath id="clipper" clipPathUnits="objectBoundingBox">
<path d="M0,0 0.5,0.07 1,0 1,1 0,1z" />
</clipPath>
</defs>
</svg>
<div class='shape'></div>
Hide resultSVG path polygon ( clip-path) , , SVG- ( , , , ).