I want to achieve something like this - it has a background image. I only able to make a slanted div like this-
.shape {
position: relative;
width: 100%;
height: 290px;
background: rgba(6, 180, 248, 1);
}
.shape:after {
position: absolute;
width: 100%;
height: 100%;
content: "";
background: inherit;
top: 0;
right: 0;
bottom: 0;
left: 0;
transform-origin: top left;
transform: skewY(-4deg);
}
<br><br><br>
<section class="container">
<div class="shape">
</div>
</section>
but how can I make it transparent with a background image? can anyone please help me
CSS Code: Step 1: First, provide background to both sections and set width to 100% and height can be set according to need. Step 2: Now, use before selector on bottom section and decrease its width to 50% as we want our border to be skewed from the center. Height can be set as per the requirement.
To create a transparent background for an image, follow these steps: Step 1: Go to Wondershare PixCut, click on Upload Image to upload the image. Step 2: Wait for its background eraser to make the picture's background transparent. Step 3: Click on Download Free to download the picture with transparent background.
here i tried the example, i hope this will help you ,just copy the entire code in an html page and see the output..., or see snippet below
.hero img {
-webkit-clip-path: polygon(0 0, 100% 0, 100% 96%, 0 100%);
clip-path: polygon(0 0, 100% 0, 100% 96%, 0 100%);
}
.promo {
-webkit-clip-path: polygon(0 0, 1600px 0, 1600px 87%, 0 100%);
clip-path: polygon(0 0, 1600px 0, 1600px 87%, 0 100%);
}
.hero {
color: #fff;
font-family: 'Fira Sans', sans-serif;
position: relative;
text-align: center;
text-shadow: 0px 0px 1px rgba(0, 0, 0, 0.5);
}
.hero img {
width: 100%;
}
.hero figcaption {
left: 50%;
position: absolute;
top: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
width: 100%;
}
.hero h1 {
font-size: 32px;
}
.hero p {
font-size: 14px;
font-weight: 300;
margin-top: 0.5em;
}
.promo {
background: url(https://tractionnext.com/wp-content/uploads/2019/01/book-demo-hero-background.jpg) no-repeat;
background-size: cover;
color: #fff;
font-family: 'Fira Sans', sans-serif;
margin: 50px 0;
overflow: hidden;
padding: 150px 20px;
position: relative;
text-align: center;
text-shadow: 0px 0px 1px rgba(0, 0, 0, 0.5);
}
.promo h1 {
font-size: 32px;
}
.promo p {
font-size: 14px;
font-weight: 300;
margin-top: 0.5em;
}
.quote {
background: #41ade5;
position: relative;
z-index: 1;
}
.quote:before, .quote:after {
background: inherit;
content: '';
display: block;
height: 50%;
left: 0;
position: absolute;
right: 0;
z-index: -1;
}
.quote:before {
top: 0;
-webkit-transform: skewY(1.5deg);
transform: skewY(1.5deg);
-webkit-transform-origin: 100% 0;
transform-origin: 100% 0;
}
.quote:after {
bottom: 0;
-webkit-transform: skewY(-1.5deg);
transform: skewY(-1.5deg);
-webkit-transform-origin: 100%;
transform-origin: 100%;
}
.quote {
color: #fff;
font-family: 'Fira Sans', sans-serif;
margin: 50px 0;
padding: 20% 20px;
text-align: center;
}
h1 {
font-size: 32px;
font-weight: 500;
}
.edge--bottom {
position: relative;
z-index: 1;
}
.edge--bottom:after {
background: inherit;
content: '';
display: block;
height: 50%;
left: 0;
position: absolute;
right: 0;
z-index: -1;
}
.edge--bottom:after {
bottom: 0;
-webkit-transform: skewY(-1.5deg);
transform: skewY(-1.5deg);
-webkit-transform-origin: 100%;
transform-origin: 100%;
}
.edge--bottom--reverse {
position: relative;
z-index: 1;
}
.edge--bottom--reverse:after {
background: inherit;
content: '';
display: block;
height: 50%;
left: 0;
position: absolute;
right: 0;
z-index: -1;
}
.edge--bottom--reverse:after {
bottom: 0;
-webkit-transform: skewY(1.5deg);
transform: skewY(1.5deg);
-webkit-transform-origin: 0 100%;
transform-origin: 0 100%;
}
.edge--top {
position: relative;
z-index: 1;
}
.edge--top:before {
background: inherit;
content: '';
display: block;
height: 50%;
left: 0;
position: absolute;
right: 0;
z-index: -1;
}
.edge--top:before {
top: 0;
-webkit-transform: skewY(1.5deg);
transform: skewY(1.5deg);
-webkit-transform-origin: 100% 0;
transform-origin: 100% 0;
}
.edge--top--reverse {
position: relative;
z-index: 1;
}
.edge--top--reverse:before {
background: inherit;
content: '';
display: block;
height: 50%;
left: 0;
position: absolute;
right: 0;
z-index: -1;
}
.edge--top--reverse:before {
top: 0;
-webkit-transform: skewY(-1.5deg);
transform: skewY(-1.5deg);
-webkit-transform-origin: 0 0;
transform-origin: 0 0;
}
.edge--both {
position: relative;
z-index: 1;
}
.edge--both:before, .edge--both:after {
background: inherit;
content: '';
display: block;
height: 50%;
left: 0;
position: absolute;
right: 0;
z-index: -1;
}
.edge--both:before {
top: 0;
-webkit-transform: skewY(1.5deg);
transform: skewY(1.5deg);
-webkit-transform-origin: 100% 0;
transform-origin: 100% 0;
}
.edge--both:after {
bottom: 0;
-webkit-transform: skewY(-1.5deg);
transform: skewY(-1.5deg);
-webkit-transform-origin: 100%;
transform-origin: 100%;
}
.edge--both--reverse {
position: relative;
z-index: 1;
}
.edge--both--reverse:before, .edge--both--reverse:after {
background: inherit;
content: '';
display: block;
height: 50%;
left: 0;
position: absolute;
right: 0;
z-index: -1;
}
.edge--both--reverse:before {
top: 0;
-webkit-transform: skewY(-1.5deg);
transform: skewY(-1.5deg);
-webkit-transform-origin: 0 0;
transform-origin: 0 0;
}
.edge--both--reverse:after {
bottom: 0;
-webkit-transform: skewY(1.5deg);
transform: skewY(1.5deg);
-webkit-transform-origin: 0 0;
transform-origin: 0 0;
}
.-berry {
background: #b52b4a;
}
.-blue {
background: #41ade5;
}
.-orange {
background: #de6628;
}
.-green {
background: #5e9b42;
}
.block {
color: #fff;
font-family: 'Fira Sans', sans-serif;
margin: 0 0 200px;
padding: 20% 20px;
text-align: center;
}
h1 {
font-size: 32px;
font-weight: 500;
}
p {
font-size: 14px;
font-weight: 300;
margin-top: 0.5em;
}
<div class="hero">
<figure>
<img src="https://tractionnext.com/wp-content/uploads/2019/01/book-demo-hero-background.jpg" /><figcaption>
<h1>
Angled Edge
</h1>
<p>
Image with CSS clip-path
</p>
</figcaption>
</figure>
</div>
<div class="promo">
<h1>
Angled Edge
</h1>
<p>
CSS background with CSS clip-path
</p>
</div>
<div class="quote">
<h1>
Angled Edges
</h1>
<p>
With 2 Pseudo Elements
</p>
</div>
<div class="block -berry edge--bottom">
<h1>
Bottom Angled Edge
</h1>
</div>
<div class="block -blue edge--bottom--reverse">
<h1>
Bottom Angled Edge
</h1>
<p>
Reversed
</p>
</div>
<div class="block -berry edge--top">
<h1>
Top Angled Edge
</h1>
</div>
<div class="block -blue edge--top--reverse">
<h1>
Top Angled Edge
</h1>
<p>
Reversed
</p>
</div>
<div class="block -orange edge--both">
<h1>
Top & Bottom Angled Edges
</h1>
</div>
<div class="block -green edge--both--reverse">
<h1>
Top & Bottom Angled Edges
</h1>
<p>
Reversed
</p>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With