標籤: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分下載示範資源】