Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
212 views
in Technique[技术] by (71.8m points)

html - 如何以HTML显示Base64图像?(How to display Base64 images in HTML?)

I'm having trouble displaying a Base64 image inline.

(我在内联显示Base64图像时遇到问题。)

Can someone point me in the right direction?

(有人可以指出我正确的方向吗?)

<!DOCTYPE html>
<html>
  <head>
    <title>Display Image</title>
  </head>
  <body>
    <img style='display:block; width:100px;height:100px;' id='base64image'                 
       src='data:image/jpeg;base64, LzlqLzRBQ...<!-- base64 data -->' />
  </body>
</html>
  ask by Christopher translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

My suspect is of course actual base64 data, otherwise it looks good to me.

(我的怀疑当然是实际的base64数据,否则对我来说不错。)

See this fiddle where similar scheme is working.

(在类似的方案正在起作用的地方,请参见此提琴 。)

You may try specifying char set.

(您可以尝试指定字符集。)

 <div> <p>Taken from wikpedia</p> <img src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUA AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO 9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot" /> </div> 

You can try this base64 decoder to see if your base64 data is correct or not.

(您可以尝试使用base64解码器查看base64数据是否正确。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...