想象一下:有一个背景分配给“body”和一个白色的“div”,其中有文本。这段文字让我们可以通过它看到背景。如何实现与CSS?像这样:如何在非透明背景上创建透明文本
-1
A
回答
2
您可以使用SVG创建这个和应用mask
body {
margin: 0;
padding: 0;
display: flex;
align-items: center;
justify-content: center;
background: url('http://blog.oxforddictionaries.com/wp-content/uploads/mountain-names.jpg');
background-size: cover;
height: 100vh;
background-position: center;
font-family: 'Open Sans', sans-serif;
}
svg {
width: 300px;
height: 100px;
}
svg text {
text-anchor: middle;
}
svg #overlay {
fill: white;
opacity: 0.7;
}
svg #text {
font-size: 40px;
font-weight: bold;
}
svg #r {
fill: white;
mask: url(#mask);
}
<svg>
<defs>
<mask id="mask" x="0" y="0" width="100%" height="100%">
<rect id="overlay" x="0" y="0" width="100%" height="100%" />
<text id="text" x="50%" y="0" dy="65px">LOREM ISPUM</text>
</mask>
</defs>
<rect id="r" x="0" y="0" width="100%" height="100%" />
</svg>
0
使用不透明度;
HTML:
<body>
<div class='frontimage'>
</div>
</body>
CSS:
body{
background-image: url("yourimage.jpg");
}
.frontimage{
background-image: url("yourotherimage.jpg");
opacity: 0.5;
}
0
与CSS,你可以使用不透明度:0.6; (0 =全透明 - 1 =完全可见)。
*{font-family:Helvetica, Arial, Sans-Serif;}
.background{background:url(http://www.paisajesbonitos.org/wp-content/uploads/2015/11/paisajes-bonitos-de-oto%C3%B1o-lago.jpg);}
.text{font-size: 5em; font-weight:bold; opacity:0.6;}
<div class="background">
<span class="text">
Lorem ipsum
</span>
</div>
相关问题
- 1. 如何用透明背景创建uiview?
- 2. 如何创建透明背景?
- 3. 透明背景,明文?
- 4. 透明背景
- 5. 透明背景上的纯文本
- 6. 在WPF中创建透明背景
- 7. 使图像透明在IE中显示非透明背景
- 8. 在视图中具有非透明文本的透明背景图像
- 9. 透明背景透明图像问题
- 10. DIV上的透明背景
- 11. 不透明的背景,但没有不透明度文本
- 12. AQGridViewCell透明背景
- 13. AS3透明背景
- 14. PHP:透明背景
- 15. Div背景透明
- 16. Pygame透明背景
- 17. html透明背景
- 18. Imageview背景透明
- 19. 透明JFrame背景
- 20. TTStyledTextLabel透明背景
- 21. 与透明背景
- 22. Iframe透明背景
- 23. UIToolBar背景透明
- 24. AChartEngine透明背景
- 25. 与透明背景
- 26. webview透明背景
- 27. 与透明背景
- 28. css背景透明
- 29. WPF透明背景
- 30. Recyclerview透明背景
我们应有的尝试? –
你能不能展示一些代码或者一些例子? – aavrug
我认为这是[http://stackoverflow.com/questions/10835500/how-to-change-text-transparency-in-html-css](http://stackoverflow.com/questions/10835500/如何改变文本透明度在html-css) – Corporalis