Blocky gradient effect in CSS3

前端 未结 5 1564
后悔当初
后悔当初 2020-11-29 11:43

Is it possible to make the below gradient look more \"blocky\", so that instead of switching from green to red gradually, it\'s done in steps like the below picture?

5条回答
  •  旧巷少年郎
    2020-11-29 12:05

    Use multiple stops (although you need to define the substeps, it cannot be done automatically)

    #gradients {
      background-image: linear-gradient(to right, 
        green       0%,     green       14.28%,
        greenyellow 14.28%, greenyellow 28.58%,
        yellow      28.58%, yellow      42.85%, 
        orange      42.85%, orange      57.14%,
        darkorange  57.14%, darkorange  71.42%, 
        red         71.42%, red         85.71%, 
        brown       85.71%);
    }

提交回复
热议问题