Gradient Blend Multiple Images

后端 未结 2 1880
北海茫月
北海茫月 2021-01-22 15:16

How to make multiple images gradient blend to each other at only certain area as in the attached image below using CSS?

What I\'ve tried:

2条回答
  •  面向向阳花
    2021-01-22 15:55

    You can combine the background: linear-gradient() with Flexbox to achieve something like this:

    div {
      display: flex; /* displays flex-items (children) inline */
      justify-content: space-around; /* horizontal alignment / icons are evenly distributed with equal space around them, i.e. all have equal space on both sides, that's why there are two units of space between them / you can also experiment with other values such as: "space-between", "space-evenly", "center" etc. */
      align-items: center; /* vertically centered */
      height: 100px;
      background: linear-gradient(to right, #c3986b 45%, #0a4b67 55%); /* adjust the % to your needs, the sum of both needs to evaluate to 100% */
    }
    
    img {border-radius: 50%}
    icon1 icon2

    In the given example I've made the linear-gradient() to be 10% of parent's width. The number is calculated by subtraction of both values in %, 55% - 45%.

    In order to increase its width, if so desired, just increase the bigger number and decrease the lower one, preferably by the same amount of %, e.g. 40% / 60%, to leave it horizontally centered. For decreasing its width, just do the opposite.

提交回复
热议问题