HTML 5--adding Images

mac2022-06-30  18

 

 

一.在浏览器中插入图片:

 

(1)图片文件和当前文件在同一个路径下;

1 <!doctype html><html> 2 <head> 3 <!--<base href="/公共性文档/"></base>--> 4 </head> 5 <body> 6 <img src="1..jpg"> 7 </body> 8 </html>

 

(2)图片文件和当前文件不在同一个路径下:

1 <!doctype html><html> 2 <head> 3 <base href="/公共性文档/"></base> 4 </head> 5 <body> 6 <img src="1..jpg"> 7 </body> 8 </html>

 

二.

如果无法显示,浏览器将用文本代替图片:

1 <!doctype html><html> 2 <head> 3 <base href="/公共性文档/"></base> 4 </head> 5 <body> 6 <img src="1..jpg" alt="DeluceRoom"> 7 </body> 8 </html>

在旧版本的IE中测试结果:

三.限制图片的宽和高:(可能需要做等比例缩放处理)

1 <!doctype html><html> 2 <head> 3 <base href="/公共性文档/"></base> 4 </head> 5 <body> 6 <img src="1..jpg" alt="DeluceRoom Hotel" width="304" height="228"> 7 </body> 8 </html>

测试结果:

 

转载于:https://www.cnblogs.com/Catherinezhilin/p/8805125.html

相关资源:JAVA上百实例源码以及开源项目
最新回复(0)