如何更改对页弹出窗口的背景色?

2024-05-19 01:18:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我在为地图可视化而工作。你知道如何将弹出窗口的背景颜色从白色改为其他颜色吗?在

从这里How can I change the background color of a Leaflet popup?我知道这可能直接在传单上,但我发现任何与叶有关的东西!在

谢谢你!在


Tags: ofthe颜色可视化地图changecanhow
1条回答
网友
1楼 · 发布于 2024-05-19 01:18:01

选项1(手动):

用编辑器软件打开您的.html文件,并在<style>标记中粘贴以下内容:.leaflet-popup-content-wrapper {background-color:black; color:white}

选项2(自动化):

创建地图并将其保存在path中。 然后使用BeautifulSoup。在

from bs4 import BeautifulSoup
path = 'your/path/map.html'
soup = BeautifulSoup(open(path), "html.parser")
head = soup.head
head.append(soup.new_tag('style', type='text/css'))
head.style.append(' .leaflet-popup-content-wrapper {background-color:black; color:white}')
with open(path, "w") as file: file.write(str(soup))

相关问题 更多 >

    热门问题