To apply a gradient border on an irregular shape using a pseudo-element, follow these steps:
<div class="irregular-shape">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
.irregular-shape {
position: relative;
width: 200px;
height: 150px;
background-color: #ccc;
}
.irregular-shape::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
}
.irregular-shape::before {
background: linear-gradient(to right, #f00, #00f);
}
/* or */
.irregular-shape::before {
background: radial-gradient(circle at center, #f00, #00f);
}
.irregular-shape::before {
transform: skew(30deg);
transform-origin: bottom;
}
Here's the complete CSS example:
.irregular-shape {
position: relative;
width: 200px;
height: 150px;
background-color: #ccc;
}
.irregular-shape::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
background: linear-gradient(to right, #f00, #00f);
transform: skew(30deg);
transform-origin: bottom;
}
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-07-07 12:50:20 +0000
Seen: 11 times
Last updated: Jul 07 '23
How to give an <svg> element a double border using CSS when there is no style attribute present?
Why does the fixed position interfere with the functionality of overflow hidden?
How can I customize the Swiper Element v9 in ionic 6 with stylish design?
What is the method of using relative position in CSS?
What is a more effective method to verify the type of an Array containing elements of any type?
What is the method for placing an element beside a relative element?