добавить фильтр сглаживания градиента на изображение - PullRequest
0 голосов
/ 23 февраля 2019

У меня есть фоновое изображение, и я хочу добавить на него два градиентных фильтра ... первый фильтр - синий синий справа налево, что нормально, а второй фильтр - черный фильтр сверху вниз, который не является плавным привсе.Я хочу, чтобы мой код генерировал это: https://dribbble.com/shots/2595241-VOID-Conference/attachments/516900, но мой черный фильтр испортил его.

* {
  box-sizing: border-box;
  padding: 0;
  margin: 0;
}

html,
body {
  height: 100%;
}

.landing {
  width: 100vw;
  height: 100vh;
  position: relative;
}

.landing .bg {
  width: 100%;
  height: 100%;
  position: absolute;
  background: url('https://images.unsplash.com/photo-1448574271786-c15eea67e169?ixlib=rb-1.2.1&q=85&fm=jpg&crop=entropy&cs=srgb&dl=sebastian-unrau-48222-unsplash.jpg') center top no-repeat;
  background-size: 100% 75%;
}

.landing .bg::before {
  content: '';
  width: 100%;
  height: 75%;
  position: absolute;
  background-image: linear-gradient(to right, rgb(0, 50, 150) 0%, rgb(0, 25, 50) 100%);
  opacity: .2;
}

.landing .bg::after {
  content: '';
  width: 100%;
  height: 100%;
  position: absolute;
  background-image: linear-gradient(to bottom, transparent 40%, rgb(20, 20, 20) 60%);
}
<div class="landing">
  <div class="bg"></div>
</div>

Ответы [ 3 ]

0 голосов
/ 23 февраля 2019

<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    * {
      box-sizing: border-box;
      padding: 0;
      margin: 0;
    }
    
    html,
    body {
      height: 100%;
    }
    
    .landing {
      width: 100vw;
      height: 100vh;
      position: relative;
    }
    
    .landing .bg {
      width: 100%;
      height: 100%;
      position: absolute;
      background: url('https://images.unsplash.com/photo-1448574271786-c15eea67e169?ixlib=rb-1.2.1&q=85&fm=jpg&crop=entropy&cs=srgb&dl=sebastian-unrau-48222-unsplash.jpg') center top no-repeat;
      background-size: 100% 100%;
    }
    
    .landing .bg::before {
      content: '';
      width: 100%;
      height: 100%;
      position: absolute;
      background-image: linear-gradient(to right, rgb(0, 50, 150) 0%, rgb(0, 25, 50) 100%);
      opacity: .2;
    }
    
    .landing .bg::after {
      content: '';
      width: 100%;
      height: 100%;
      position: absolute;
      background-image: linear-gradient(to bottom, transparent 40%, rgb(20, 20, 20) 60%);
      opacity: 0.2
    }
  </style>
</head>

<body>
  <div class="landing">
    <div class="bg"></div>
  </div>
</body>

</html>

Я внес изменения в CSS.Надеюсь, это решит вашу проблему.

0 голосов
/ 23 февраля 2019

Вы можете упростить свой код, используя несколько фонов:

* {
  box-sizing: border-box;
  padding: 0;
  margin: 0;
}

html,
body {
  height: 100%;
}

.landing {
  height: 100vh;
  background: 
    linear-gradient(to bottom, transparent 40%, rgba(20, 20, 20,0.8) 80%),
    linear-gradient(to right, rgba(0, 50, 150, 0.2) 0%, rgba(0, 25, 50, 0.2) 100%),
    url('https://images.unsplash.com/photo-1448574271786-c15eea67e169?ixlib=rb-1.2.1&q=85&fm=jpg&crop=entropy&cs=srgb&dl=sebastian-unrau-48222-unsplash.jpg') top;
  background-size: 100% 75%;
  background-repeat:no-repeat;
}
<div class="landing">
</div>
0 голосов
/ 23 февраля 2019

Добавьте непрозрачность и установите высоту фона снизу вверх, так же, как слева направо

* {
  box-sizing: border-box;
  padding: 0;
  margin: 0;
}

html,
body {
  height: 100%;
}

.landing {
  width: 100vw;
  height: 100vh;
  position: relative;
}

.landing .bg {
  width: 100%;
  height: 100%;
  position: absolute;
  background: url('https://images.unsplash.com/photo-1448574271786-c15eea67e169?ixlib=rb-1.2.1&q=85&fm=jpg&crop=entropy&cs=srgb&dl=sebastian-unrau-48222-unsplash.jpg') center top no-repeat;
  background-size: 100% 75%;
}

.landing .bg::before {
  content: '';
  width: 100%;
  height: 75%;
  position: absolute;
  background-image: linear-gradient(to right, rgb(0, 50, 150) 0%, rgb(0, 25, 50) 100%);
  opacity: .2;
}

.landing .bg::after {
  content: '';
  width: 100%;
  height: 75%;
  position: absolute;
  background-image: linear-gradient(to bottom, transparent 40%, rgb(20, 20, 20) 60%);
  opacity: 0.6;
}
<div class="landing">
  <div class="bg"></div>
</div>
...