css實現純文字內容元素透明背景(相容IE6)

來源:互聯網
上載者:User

標籤:

HTML:

<div class="title-wrapper">            <span class="title">                <span class="icon sp-index sp-index-tag-bg">                    <i class="mood2 sp-base"></i>                </span>                <span class="txt">                    <span class="occupy">吳奇隆機場推行李車 劉詩詩走其身側秀美腿</span>                    <a href="/" target="_blank">吳奇隆機場推行李車 劉詩詩走其身側秀美腿</a>                </span>            </span>          </div>

CSS:

.focus-r{width:480px;}.focus-r-base{width:480px;height:270px;position:relative;overflow:hidden;}.focus-r-base .title-wrapper{width: 100%;height: 50px;position: absolute;bottom: 12px;text-align: center;}.focus-r-base .title-wrapper .title{display: inline-block; }.focus-r-base .title-wrapper .icon{width: 50px;height: 50px; float: left;}.focus-r-base .title-wrapper .icon i{display: inline-block;width: 33px;height: 33px; margin-top: 8px; text-indent: 0;}.focus-r-base .title-wrapper .txt{float: left; height:34px;line-height:34px; padding-top: 8px; color:#fff;font-size: 14px; word-spacing: 0;}.focus-r-base .title-wrapper .txt .occupy{position: absolute; top: 8px; background: #000; filter:Alpha(opacity=60); opacity:.6; padding-right: 10px; border-radius:0 15px 15px 0;}.focus-r-base .title-wrapper .txt a{color:#fff; padding-right: 10px; position: relative; z-index: 1;}

 

  以上是主要的代碼,有幾點需要注意:

  • 利用rgba實現有相容性的問題,所以採用兩層覆蓋的方法
  • float元素與position:absolute元素平級時,當絕對位置沒有指定top/left時,float會在絕對位置元素前面出現
  • 絕對位置元素當不指定top/left時,則相對於offsetParent內容區定位(不同瀏覽器有差異);當指定top/left時,則相對於offsetParent的margin負邊距定位
  • inline-block元素間空隙問題,除了可以刪除html中的空格外,也可以設定其word-spacing為負數
  • z-index只適用新的層疊上下文,建立新的層疊內容相關的屬性有絕對/相對定位及一些css3屬性。故本文在用z-index時,把元素設為了相對定位

css實現純文字內容元素透明背景(相容IE6)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.