This article discusses the difficulties and ideas of the linear gradient concave rectangle transition effect. It mainly introduces the implementation of concave rectangle, adding linear gradient to concave rectangle, and the transition of linear gradient background color. If you have a better implementation solution, please feel free to discuss with me in the comment section. Above Implementing a concave rectangle The inspiration for implementing this style comes from an article on the Internet that uses CSS to achieve concave corners. It describes how to achieve the concave corner effect of Chrome tabs, which is roughly as follows: Use You can debug it in the radial gradient demo on MDN: background: radial-gradient(300px 300px at 112px 0, #eee 75%, #333 75%); Small details
Concave rectangle with linear gradient In the previous section, we have implemented a concave rectangle. So how do we set a linear gradient for the concave rectangle? The background is already in use. You cannot set both radial and linear gradients. You can use The MDN example uses a five-pointed star svg to cut out a green five-pointed star on a green background. To achieve a gradient concave rectangle, you can use a concave rectangle shape to cut out a linear gradient background. Use .xxx { background: linear-gradient(115deg, #ff66ff, #4db8ff); mask-image: radial-gradient(300px 300px at 112px 0, rgba(255, 255, 255, 0) 75%, #333 75%); } Effect: Small details Mask-image is more compatible than radial gradient on mobile devices, and is supported by Android 4.4.4. Gradient background color transition Background-image itself does not support transition animation, but it can be achieved through some fancy operations. Teacher Zhang Xinxu’s article explains it in great detail: https://www.zhangxinxu.com/wordpress/2020/08/background-image-animation/ https://www.zhangxinxu.com/wordpress/2018/03/background-gradient-transtion/ Background-image does not support transition animation, but opacity does. Add another pseudo-element on the previous linear gradient concave rectangle, set the background color of the pseudo-element to another linear gradient color, and then control the opacity of the pseudo-element to achieve a linear gradient transition effect. This concludes this article about the implementation of CSS linear gradient concave rectangle transition effect. For more relevant CSS linear gradient concave rectangle transition content, please search 123WORDPRESS.COM’s previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! |
<<: mysql data insert, update and delete details
>>: Example of fork and mutex lock process in Linux multithreading
Table of contents 1 The role of Apache 2 Apache I...
1. Purchase a server In the example, the server p...
Custom tags can be used freely in XML files and HT...
Style Sheets CSS (Cascading Style Sheets) is used...
Word MySQL 8.0 has been released for four years s...
Before further analyzing why MySQL database index...
C++ connects to MySQL for your reference. The spe...
01. Overview Absolute paths and relative paths ar...
The code looks like this: <!DOCTYPE html> &...
The front-end development department is growing, ...
There are many Hadoop installation tutorials on L...
This article shares the specific code of writing ...
1. Download the MySQL installation package (there...
This article shares the specific code of Vue3.0 h...
1. Installation Instructions Compared with local ...