-5

嗨,我想在我网站的横幅图像上制作一个灰色 (#444) 曲线叠加。我附上了我想要的图片。

在此处输入图像描述

4

3 回答 3

3

这可以通过使用 CSS 径向渐变来实现。

您可以使用额外的 div,或者如果您愿意,也可以使用伪元素。

我已经使用了多个 div 来向您展示它是如何构建在一起的。

.container {
  width: 900px;
  height: 300px;
  position: relative;
}
.overlay {
  width: 100%;
  height: 100%;
  position: absolute;
  left: 0;
  top: 0;
  background: -webkit-radial-gradient(100% 21.875%, transparent 0%, transparent 20%, #444 45%);
  background: radial-gradient(at 100% 21.875%, transparent 0%, transparent 20%, #444 45%);
  background-size: 100% 225%;
}
.overlay .text {
  width: 50%;
  padding: 20px;
  color: white;
}
<div class="container">
  <img src="http://lorempixel.com/900/300/" width="100%" height="auto" />
  <div class="overlay">
    <div class="text">
      <p>Some Text</p>
    </div>
  </div>
</div>

于 2016-01-17T13:18:06.513 回答
2

您可以使用多个背景和radial-gradient. 这是一个例子。

编辑这是该示例中的 CSS。

#banner{
   width:400px;
   height:200px;
   background:radial-gradient(circle farthest-corner at 100% 50%,rgba(68,68,68,0) 60%,#444 70%),url(https://upload.wikimedia.org/wikipedia/commons/thumb/5/5c/Sun-in-the-sky.jpg/800px-Sun-in-the-sky.jpg);
   background-size:cover;
}
于 2016-01-17T13:17:56.307 回答
0

绝对定位的 div 作为覆盖

使用覆盖和绝对位置,您可以创建灰色覆盖。

.container {
  position: absolute;
  display: inline-block;
  width: 400px;
  height: 200px;
  background-color: #444;
  background-image: url("http://www.lorempixel.com/400/200/");
  color: white;
  overflow: hidden;
}
.overlay {
  position: absolute;
  width: 70%;
  height: 150%;
  background: radial-gradient(ellipse at 100% 50%, transparent 40%,  #444 60%);
  top: -25%;
}
.container p {
  position: relative;
  margin-left: 2em;
}
<div class="container">
  <div class="overlay"></div>
  <p>Text</p>
</div>

于 2016-01-17T13:28:14.397 回答