如何使圖片陰影自動調整:shrink-wraps

來源:互聯網
上載者:User
首先,先來看一個簡單的例子:

測試一

HTML代碼:

1 <div style="background-color: gray;">測試一</div>

 

我們現在給上面的例子中,CSS添加float屬性,你會發現一些小小的變動,也許你認為這沒什麼,今天要講的主題就是由這個小小的變化衍生而來的;

測試二

HTML代碼:

1 <div style="background-color: gray; float: left;">測試二</div>

 

 你現在可以看到:測試二中的DIV是隨著你內容的增加自動調整的。啊,yes...把這個效果應用到背景陰影裡會出現什麼效果呢?

1、不用給包裹的DIV設定固定寬度了

2、能根據圖片的大小自動調整

摘處:CSS Mastery

CSS代碼:

 1.img-wrapper {}{
 2  background: url(images/shadow.gif) no-repeat bottom right;
 3  clear: both;
 4  float: left;
 5  position: relative;
 6  margin: 10px 0 0 10px;
 7}
 8 
 9.img-wrapper img {}{
10  background-color: #fff;
11  border: 1px solid #a9a9a9;
12  padding: 4px;
13  display: block;
14  margin: -5px 5px 5px -5px;
15  position: relative;
16}HTML代碼:

1 <div class="img-wrapper"><img src="images/dunstan.jpg" width="300" height="300" alt="Dunstan Orchard" /></div>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.