Css 背景图像,Tornado 提供图像

0 投票
1 回答
559 浏览
提问于 2025-04-18 17:52

我在用tornado搭建一个图片服务器,代码是:

class Index(tornado.web.RequestHandler):
    def get(self):
       header = "image/png"
       ifile = open("image.png","r")
       self.add_header("Content-Type",header) 
       self.write(ifile.read()) 

我在网页上用这个图片,像这样:<img src="http://localhost:8888/img" />,这样是没问题的。但是当我想在CSS的背景图片里用这个链接时,就不行了,比如:<div style="background-image:url(http://localhost:8888/img)"></div>

1 个回答

2

你的说法是对的,但是这个dev的高度是0,所以它没有显示出来。

<div style="background-image:url(http://localhost:8888/img); min-height: 100px; background-repeat: repeat;">&nbsp;</div>

撰写回答