用CSS設定的4種樣式的圖片說明文本之03

來源:互聯網
上載者:User

浮在圖片的半透明說明文本之二1、2、HTML代碼
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><!--meta標記定義的字元集是支援中文的gb2312--><meta http-equiv=content-type content="text/html; charset=gb2312"><!--連結外部CSS樣式 --><link rel="stylesheet" href="captions-2b.css" type="text/css" media="screen" /><title>圖片解說文字</title><!--[if lt IE 7]><style type="text/css">.captioned_photo p {background: none;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale, src='images/caption-white.png');}</style><![endif]--></head><body>          <div class="captioned_photo"> <img src="images/captions-2.jpg" alt="Cat Vase!" />               <p><span><strong>The Cat Vase:</strong> The cats are cute, white,                         with gold-trimmed ears and tails.</span></p>          </div></body></html>

3、CSS代碼

/*CSS STYLE SHEET FOR [captions-2a.html] Created by [Serein_Chan]Email: [Serein_Chan@foxmail.com]Author Blog:[http://blog.csdn.net/cxwen78]*//*注釋 *//*body的樣式 */body {margin: 0;padding: 0;background-color: #fff;font: 62.5% Verdana, sans-serif;color: #4d4d4d;}p {margin: 0;padding: 0 0 1em 0;}.captioned_photo {position: relative;/*設定DIV塊的定位類型,使得其所包含的子項目P進行絕對位置時能相對於DIV塊來定位而不是HTML元素*/width: 240px;display: block;margin: 1em 1em 1em 1em;padding: 1em;border: 1px solid #ccc;border-top-color: #eee;border-right-color: #ddd;border-bottom-color: #bbb;background: url(images/bg.gif) bottom left repeat-x;/*DIV塊的漸層背景*/line-height: 1em;text-align: left;}.captioned_photo p {position: absolute;/*絕對位置相對於最近的已定位的祖先元素*/bottom: 2.25em;left: 1.375em;display: block;width: 240px; /* 為了匹配圖片寬度而設定 */margin: 0;padding: 0;background: url(images/caption-black.png) top left repeat-y;/*使用半透明的圖片作背景實現透明層疊效果*/font: .9em Verdana, sans-serif;letter-spacing:.05em;/*設定字元間的空白*/color: #fff;}.captioned_photo p span {display: block;padding: 1em;}.captioned_photo img {margin: 0 0 -.0625em 0;padding: 0;}

參考:《The Art & Science of CSS》

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.