以HTML显示文本文件

问题描述:

我试图在不使用ajax,javascript ecc的情况下以html显示文本文件的内容.但可能是CSS和HTML.我有图像的幻灯片显示,根据您选择的图像,文本文件的内容应出现在照片下方.我知道如何将文本文件与照片相关联,并且应该可以工作,但是如何在网页中显示txt文件的内容?谢谢:-)

I'm trying to display the content of a text file in html without using ajax, javascript ecc. but possibly css and html. I have a slideshow of images and depending on the image you select, the content of the text file should appear under the photo. I know how to associate the text file with the photo and it should work, but how can I can display the content of the txt file in the web page? Thanks :-)

您可以只使用

You can just use an <iframe>:

<iframe src="http://stackoverflow.com/reputation"></iframe>

堆栈溢出不再允许< iframe> 进入其他域,因此我改用了//stackoverflow.com/reputations用于演示

Stack Overflow no longer allows <iframe>'s to a different domain, so I switched to using //stackoverflow.com/reputations for the demos

这可能是您正在寻找的(图片下方带有文字的文字):

This is probably more what you are looking for(Image with text below it):

iframe{
    border:none;
    width:400px;
    display:block;
}

<img src="http://lorempixel.com/400/400">
<iframe src="http://stackoverflow.com/reputation"></iframe>