HTML CSS——zoom的學習

來源:互聯網
上載者:User

標籤:style   class   blog   code   http   tar   

        上大學做階段項目時遇到了一個很奇特的現象:kindEditor上傳圖片功能失效,但是把jsp所引用的樣式去掉就好用,這說明樣式有問題,於是刪一個樣式測試一下,就這樣罪魁禍首落在了zoom身上,這是我們第一次"相識",今天周末,難得的清閑,現總結一下:

        首先說一下zoom的作用:zoom用來設定對象的縮放比例;

        zoom屬性值:normal | <number> | <percentage>

        一、normal:

        代碼1-1如下:

<!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">      <head>          <meta http-equiv="Content-type" content="text/html; charset=UTF-8" />  <style type="text/css">.test{zoom:normal;}</style></head><body><h1 style="font-size:5pt;">zoom</h1><h1>zoom</h1><h1 class="test">zoom</h1></body></html>
圖1-1

        代碼1-2如下:

<!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">      <head>          <meta http-equiv="Content-type" content="text/html; charset=UTF-8" />  <style type="text/css">.test{zoom:normal;}</style></head><body><img src="./test.png" width = "50" height = "50"></img><br><img src="./test.png"></img><br><img src="./test.png" class="test"></img></body></html>

圖1-2        總結:        a、圖1-1:從代碼中可以看到第一個“zoom”的字型大小為“5pt”,第二個“zoom”的字型大小使用了預設值,第三個“zoom”的字型添加了“zoom:normal;”樣式列表;        b、圖1-2從代碼中可以看到第一副圖片的寬為“50”,高也為“50”大小為“5pt”,第二副圖片大小使用了預設值,第三副圖片添加了“zoom:normal;”樣式列表;        通過a和b兩點的描述我們可以得到這樣一個結論:normal用來使元素使用其實際尺寸;

        二、<number>:用浮點數來定義縮放比例。不允許負值;

        代碼2-1如下:

<!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">      <head>          <meta http-equiv="Content-type" content="text/html; charset=UTF-8" />  <style type="text/css">.test{zoom:3;}</style></head><body><h1>zoom</h1><h1 class="test">zoom</h1></body></html>

圖2-1

        代碼2-2如下:

<!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">      <head>          <meta http-equiv="Content-type" content="text/html; charset=UTF-8" />  <style type="text/css">.test{zoom:3;}</style></head><body><img src="./test.png"></img><br><img src="./test.png" class="test"></img></body></html>

圖2-2

        三、<percentage>:用百分比來定義縮放比例。不允許負值;

        代碼3-1如下:

<!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">      <head>          <meta http-equiv="Content-type" content="text/html; charset=UTF-8" />  <style type="text/css">.test{zoom:300%;}</style></head><body><h1>zoom</h1><h1 class="test">zoom</h1></body></html>

圖3-1

        代碼3-2如下:

<!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">      <head>          <meta http-equiv="Content-type" content="text/html; charset=UTF-8" />  <style type="text/css">.test{zoom:300%;}</style></head><body><img src="./test.png"></img><br><img src="./test.png" class="test"></img></body></html>

圖3-2

        注意:由於zoom相容性的缺陷,其實在實際的應用中並不是很多,只需一般瞭解就好。

        【0分下載示範資源】

聯繫我們

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