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

來源:互聯網
上載者: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-3.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-3.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-3.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;width: 242px;/*下面的圖片樣式設定了1px的邊框,所以多出了2px寬度*/text-align: left;display: block;margin: .5em 0 .5em 1.25em;padding: 0;border: 3px solid #333;line-height: 1em;}.captioned_photo p {position: absolute;bottom: 14px;left: 0;display: block;width: 240px; /* 這是為匹配圖片而設定的寬度 */margin: 0 0 0 1.5em;/*設定標題向左的位移量*/padding: 0;border: 1px solid #666;border-right-color: #000;border-bottom-color: #000;background-color: #111;font: .9em Verdana, sans-serif;letter-spacing:.05em;color: #fff;}.captioned_photo p span {display: block;padding: .75em;}.captioned_photo img {margin: 0;padding: 0;display: block;border:1px solid #fff;}

參考:《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.