[英]How can i display images using <img> in simple HTML 5 files?
我的問題是我可以在簡單的HTML 5文件中使用<img>
標簽顯示圖像嗎?
我在線和離線使用wampserver嘗試了下面顯示的test.html文件。 但是結果幾乎是一樣的。
文件路徑是
C:\wamp\www\fluid\SMS\test\test.html
C:\wamp\www\fluid\SMS\test\stack.jpg
C|/Users/aimme/Desktop/stack.jpg
這是test.html
<html>
<head>
</head>
<body>
<!-- works on internet explorer
doesn't work on other ff & chrome -->
<img src="file:///C|/Users/aimme/Desktop/stack.jpg" alt="stack img from my desktop" width="500" height="100"/>
<!--doesn't work on ie,ff or chrome-->
<img src="stack.png" alt="stack img from same folder" width="100" height="100"/>
<!--doesn't work on ie,ff or chrome-->
<img src="cdn.sstatic.net/stackoverflow/img/apple-touch-icon@2.png" alt="stack img from site" height="100" width="100">
</body>
</html>
這是結果。
如何在Internet Explorer 11.0.9600.17031版本中看到 在Firefox 40.0.3中如何看待 在Chrome 47.0.2503.0 dev-m(64位)中如何看待
一些東西:
"file:///C|/Users/aimme/Desktop/stack.jpg"
的豎線字符,這就是為什么它在那里失敗的原因。 stack.jpg
,則需要包含.jpg
擴展名才能起作用。 <img src="http://cdn.sstatic.net/stackoverflow/img/apple-touch-icon@2.png" alt="stack img from site" height="100" width="100">
請注意,沒有結束標記。 這是不使用它們的少數元素之一。
<img src="Desktop/stack.jpg" class="flr" alt="Lake Atitlan, Guatemala" width="300" height="240">
提供圖像的相對路徑。
有關更多詳細信息,請參考以下鏈接:
http://www.html-5-tutorial.com/image-element.htm
嘗試
<img src="stack.jpg" />
文件stack.jpg與HTML文件位於同一目錄中。
對於遠程文件,請輸入完整的URL,即http:// ...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.