Home >Web Front-end >CSS Tutorial >How can I transform a cutout top into a curved top background using CSS?
In this code-based task, we aim to transform a cutout positioned on the right side of a block into a curved shape sitting gracefully atop the block.
The current code snippet involves a .box containing a .top element. While the desired effect is to have the cutout on top, the code places it on the right. So, let's dive into the revised version:
<code class="css">.box { margin-top: 90px; width: 200px; height: 100px; background: white; position: relative; } .box:before, .box:after { content: ""; position: absolute; bottom: 100%; width: 50%; left: 0; height: 80px; background: radial-gradient(50% 100% at bottom left, #fff 98%, #0000) top, radial-gradient(50% 100% at top right, #0000 98%, #fff) bottom; background-size: 100% 50%; background-repeat: no-repeat; } .box:after { transform-origin: right; transform: scaleX(-1); } body { background: pink; }</code>
Key Adjustments:
Voilà! You now have a curved cutout flowing seamlessly from the top of the block. Feel free to experiment further and create a curve that perfectly complements your design.
The above is the detailed content of How can I transform a cutout top into a curved top background using CSS?. For more information, please follow other related articles on the PHP Chinese website!