如何在div中使用较低的不透明度来制作文本

Jon*_*vgi 7 html css svg filter clip-path

如何降低div中文本的不透明度,如下所示:

Max*_*ter 6

CSS mix-blend-mode属性将为您提供您正在寻找的效果(仅使用它无法实现opacity).如果您不需要Internet Explorer支持,则不需要SVG.此解决方案与Chrome,Firefox,Safari,Opera等兼容(请参阅此处的兼容性表).

现场演示:

html, body {
  margin: 0;
}

.mix {
  position: absolute;
  top: 0;
  left: 0;
  width: 140px;
  height: 100px;
  font-size: 80px;
  color: white;
  padding: 20px;
  margin: 10px;
  background-color: black;
  mix-blend-mode: multiply;
  opacity: 0.8;
}
Run Code Online (Sandbox Code Playgroud)
<img src="http://i.imgur.com/5LGqY2p.jpg?1">
<div class="mix">
Text
</div>
Run Code Online (Sandbox Code Playgroud)