Home  >  Article  >  Web Front-end  >  css实现的文字位于图片之上且背景半透明_html/css_WEB-ITnose

css实现的文字位于图片之上且背景半透明_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:30:231684browse

css实现的文字位于图片之上且背景半透明:
现在很多网页中都有这样的效果,就是文字说明悬浮于图片之上,并且文字的背景是半透明的,这不但美观而且也可以节省网页空间,下面就通过代码实例介绍一下如何实现此效果。
代码如下:

 

<!DOCTYPE html><html><head><meta charset=" utf-8"><meta name="author" content="http://www.softwhy.com/" /><title>蚂蚁部落</title><style> a.title{   color:#D3D3D4;   background-color:rgba(0,0,0,0.6);   filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr='#A0000000',EndColorStr='#A0000000');   padding:12px 24px;   position:absolute;   top:50px;   left:0px;  text-decoration:none;   color:#fff; }#box{  position:relative; }</style> </head> <body> <div id="box"> <img  src="mytest/demo/tree.jpg" / alt="css实现的文字位于图片之上且背景半透明_html/css_WEB-ITnose" > <a class="title" href="#">蚂蚁部落欢迎您</a> </div> </body> </html> 

 

原文地址是:http://www.softwhy.com/forum.php?mod=viewthread&tid=12803

更多内容可以参阅:http://www.softwhy.com/divcss/

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn