How to apply multiple css radial gradients to a single element

前端 未结 4 1583
-上瘾入骨i
-上瘾入骨i 2021-01-03 05:39

I have the following style applied to my div element:

background-image: -moz-radial-gradient(50% -10%, ellipse closest-corner, rgba(5, 5, 5, 0.7         


        
4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-03 06:27

    The best way to do that is to list them in the background property. But keep in mind that the order of properties is extremely important.

    background:
        radial-gradient(circle at top left, transparent 15px, #58a 0) top left,
        radial-gradient(circle at top right, transparent 15px, #58a 0) top right,
        radial-gradient(circle at bottom right, transparent 15px, #58a 0) bottom right,
        radial-gradient(circle at bottom left, transparent 15px, #58a 0) bottom left;
    background-size: 50% 50%;
    background-repeat: no-repeat;
    

    background then -size and -repeat, otherwise it won't work. It took me something like 30 mins to get it. Hope it will be helpful for someone.

提交回复
热议问题