css - 没有边框的不透明度渐变?

标签 css gradient

我在 css 中为 div 创建了一个不透明度渐变,但仍然有可见的 div 边框(黑色水平线看起来像边框底部) enter image description here

HTML:

<div className="audio-caption-background">/div>
<img className="audio-img" src="audio.jpg alt=""/>

CSS:

.audio-img {
position: absolute;
}
.audio-caption-background {
  background-color: black;
  width: 100%;
  height: 50px;
  position: absolute;
  top:0;
  z-index: 50;
  mix-blend-mode: hard-light;
}

.audio-caption-background:after {
  position: absolute;
  content: "";
  left: 0px;
  top: 0px;
  height: 100%;
  width: 100%;
  background: linear-gradient(to right, transparent, gray);
}

您可以在底部看到“边框”。我尝试将“边框:无”应用于 div,但没有成功。有没有办法摆脱它? 提前致谢

最佳答案

我更改了图像,但没有显示底部边框..您还缺少一个结束标记

.audio-img {
position: absolute;
}
.audio-caption-background {
  background-color: black;
  width: 100%;
  height: 250px;
  position: absolute;
  top:0;
  z-index: 50;
  mix-blend-mode: hard-light;
}

.audio-caption-background:after {
  position: absolute;
  content: "";
  left: 0px;
  top: 0px;
  height: 100%;
  width: 100%;
  background: linear-gradient(to right, transparent, grey);
}
<div style="position: relative;">
<div class="audio-caption-background"></div>
<img class="audio-img" height="600px" width="100%" src="https://seaduckjv.org/wp-content/themes/responsive-child/images/STEI-male-floating-TedSwem_4482-350.jpg" alt=""/>

</div>

关于css - 没有边框的不透明度渐变?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53795780/

相关文章:

r - ggplot : How to produce a gradient fill within a geom_polygon

jquery - Bootstrap jquery 不崩溃

java - 在 JavaFX 的 WebView 中使用 JavaScript 设置任意 CSS 规则

ios - 如何在导航栏中添加渐变-iOS

matlab - 如何在MatLab中找到曲线上一点的法向量

html - 如何让渐变在 Firefox 中工作

html - 表格中的背景颜色

css - 如何使用 CSS 显示 img alt 文本?

css - 可变化 CSS 类?

ios - 在 View 内的矩形内绘制简单的线性渐变