我在显示内嵌 Base64 图像时遇到问题。
我该怎么做?
<!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>
最佳答案
我的怀疑当然是实际的 Base64 数据。否则对我来说看起来不错。见 this fiddle类似的计划正在运作。您可以尝试指定字符集。
<div>
<p>Taken from wikpedia</p>
<img src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUA
AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot" />
</div>
你可以试试this Base64 decoder看看你的 Base64 数据是否正确。
关于html - 如何在 HTML 中显示 Base64 图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8499633/