Search code examples
htmlcss

How can I create this background using a gradient instead of an image?


the current code is below

.wrap {
  display: flex;
  gap: 30px;
}
.item {
  flex-basis: 382px;
  background-image: url(https://i.ibb.co/Jn6J3qN/card.png);
  background-repeat: no-repeat;
  background-size: сontain;
  flex-basis: 382px;
  min-height: 218px;
  border-radius: 20px;
  box-shadow: 0px 4px 20px 0px rgba(0, 0, 0, 0.25);
  padding: 32px;
}
<div class="wrap">
  <div class="item"></div>
  <div class="item"></div>
</div>


Solution

  • Just set .item background linear-gradient and also set parameters for it. You can use this colour picker tools, like this website: https://cssgradient.io/, to set linear-gradient parameters.

    .wrap {
      display: flex;
      gap: 30px;
    }
    .item {
      flex-basis: 382px;
      background: rgb(12,28,87);
      background: linear-gradient(156deg, rgba(12,28,87,1) 0%, 
      rgba(83,81,147,1) 100%);
      background-repeat: no-repeat;
      background-size: сontain;
      flex-basis: 382px;
      min-height: 218px;
      border-radius: 20px;
      box-shadow: 0px 4px 20px 0px rgba(0, 0, 0, 0.25);
      padding: 32px;
    }
    <div class="wrap">
      <div class="item"></div>
      <div class="item"></div>
    </div>