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. Scenario Description 2. Solu...
Using provide+inject combination in Vue First you...
Table of contents 1. Function debounce 1. What is...
This article shares the specific code of JavaScri...
Are you still using rem flexible layout? Does it ...
Docker-machine is a Docker management tool offici...
This article shares the specific code of JavaScri...
Vertical Split Vertical splitting refers to the s...
Table of contents 1. The difference between multi...
1. The component First.js has subcomponents: impo...
Copy code The code is as follows: <select> ...
1. Install the database 1) yum -y install mysql-s...
Table of contents 1. Scenario 2. Simplify the und...
Alibaba Cloud purchases servers Purchase a cloud ...
Previously, https://www.jb51.net/article/205922.h...