文本背景透明
效果图:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>文本背景透明</title> <style type="text/css"> *{padding:0;margin: 0;} body{ padding: 20px; } #cont{ width: 300px; height: 200px; background:green; background-size:contain; /* cover */ border: 1px solid #CCCCCC; position: relative; } p{ background-color:#000000; filter:Alpha(opacity=80); *zoom:1; /* 激活IE6、7的haslayout属性,让它读懂Alpha */ background: rgba(0,0,0,0.8); color: #FFF; position: absolute; bottom: 0; width: 100%; padding: 10px; box-sizing:border-box; } </style> </head> <body> <div id="cont"> <p>图片说明</p> </div> </body> </html>