背景位移取表徵圖,背景位移表徵圖

來源:互聯網
上載者:User

背景位移取表徵圖,背景位移表徵圖

  通常為了減少用戶端從伺服器下載圖片的次數,提高伺服器的效能,現在比較流行的做法是將多張圖片拼合成一張大圖片,然後再利用background-position屬性截取其中的各個小表徵圖,如菜單,表單或導航的小表徵圖等這種技術稱為CSS Sprite技術,範例程式碼如下:
html代碼如下:

<!doctype html><html lang="en"><head>  <meta charset="UTF-8"><title>背景位移取表徵圖</title><link type="text/css" rel="stylesheet" href="1.css"/></head><body>    <div id="name">name</div>    <div id="psw">psw</div>    <div id="tel">tel</div></body></html>

1.css代碼如下:

div  {     width:73px;     line-height:52px;     height:52px;     text-align:right;     background:url(images/3.jpg) no-repeat;     color:white;    } #name   {     background-position:-286px -7px;<!--向左位移286px,向上位移7px-->  } #psw   {     background-position:-272px -116px;   } #tel {     background-position:-535px -230px; }

 (要用圖片處理工具量出要截取的的表徵圖所要位移的量,正負代表位移的方向,正代表向右或向下位移,負代表向左或向上位移)

素材圖:

最終:

 

聯繫我們

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