文字透明,显示背景(附例子代码)

回复
头像
Mia2014
帖子: 1805
注册时间: 周三 12月 25, 2013 8:24 pm

文字透明,显示背景(附例子代码)

帖子 Mia2014 » 周五 2月 28, 2014 11:13 pm

实现效果: 文字透明,显示背景
代码:
opacity: 0.1; /*Chrome、Safari、Firefox、Opera */
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=1); /* IE6/IE7/8 */
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(opacity=1)"; /* IE8 */

代码解释:
第一行是在其他浏览器中使用 Opacity 属性,IE没有opacity属性;
第二行是 IE6/7/8 中使用滤镜属性设置透明度; 在 IE 滤镜中使用 0-100 表示透明度,
第三行是新的 IE 滤镜属性,它只在 IE8 中起作用在其他浏览器中会被忽略。


例子代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>透明文字,图片背景</title>
<style type="text/css">
div.words {
opacity: 0.01; /*Chrome、Safari、Firefox、Opera */
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=1); /* IE6/IE7/8 */
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(opacity=1)"; /* IE8 */
}
div.container {
position:absolute;
z-index:1;
background-image:url(http://coolder.com/theme/logo_one.png);
}
</style>
</head>

<body>
<div class="container">
<div class="words">
<a href="">These words are transparent almost.</a>
</div>
</div>
</body>
</html>

http://coolder.com 就是使用这个代码制作的菜单。

回复