Default CSS for glyphicons produces conflict with bootstrap5 components (with potential solution)
还没有人认领这个 Issue。
评估
调研方向
首先从 folium.Map 示例生成 HTML,并检查默认的样式表链接,尤其是 Bootstrap 3 CSS 和 Bootstrap 5 模态框样式。比较包含和不包含 Bootstrap 3 样式表时模态框的行为,然后验证修复是否恢复了预期的 Bootstrap 5 模态框位置,同时不会破坏 glyphicons 或其他 Folium 组件。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
Manually adding a bootstrap5 modal to the html body results in wrong position of the modal (see screenshots at the end).
To Reproduce
import folium
my_map = folium.Map()
# Adding modal from https://www.w3schools.com/bootstrap5/bootstrap_modal.php
my_map.get_root().html.add_child(folium.Element("""
<!-- Button to Open the Modal -->
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#myModal">
Open modal
</button>
<!-- The Modal -->
<div class="modal" id="myModal">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Modal Heading</h4>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<!-- Modal body -->
<div class="modal-body">
Modal body..
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
"""))
my_map.save(outfile="map.html")
Expected behavior
The modal should appear in the same way as in the bootstrap5 modal example on w3schools.
Environment:
- OS: macOS 14.0
- Browser: Firefox 118.0.1
- Python version: 3.10.7
- folium version: 0.14.0
- branca version: 0.6.0
- Plain .py, no Jupyter Notebook
Possible solutions
This issue is resolved when uncommenting the stylesheet on netdna for bootstrap 3.0.0, however, I cannot tell what the implications to other functions of folium that would have (e.g. glyphicons).
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/leaflet@1.9.3/dist/leaflet.css"/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css"/>
<!-- <link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css"/>-->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.2.0/css/all.min.css"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css"/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/python-visualization/folium/folium/templates/leaflet.awesome.rotate.min.css"/>
Screenshots
Wrong: with default CSS <link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css"/>
Correct: without default CSS <link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css"/>
- 主要语言
- Python
- 星标
- 7.4k
- 派生
- 2.3k
- 平均合并
- 17 小时 22 分钟
- 30 天内合并 PR
- 11
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
python-visualization/folium 的其他 Issue
-
documentation
难度 2/5 1-3 小时 新手友好度 68/100
python-visualization/folium#2092 · 5 条评论 ·
-
难度 3/5 1-2 天 新手友好度 67/100
python-visualization/folium#2278 · 1 条评论 ·
-
难度 5/5 一周以上 新手友好度 25/100
python-visualization/folium#2259 ·
-
Map output from OSM returns blocked tiles, due to defective request or not following referer-policy 未关闭
难度 3/5 1-2 天 新手友好度 55/100
python-visualization/folium#2236 · 5 条评论 · 1 个 reaction ·
-
难度 5/5 一周以上 新手友好度 10/100
python-visualization/folium#2219 · 2 条评论 ·
查看 python-visualization/folium 的全部 Issue
相似的 Issue
-
essnmx good first issue
难度 1/5 1 小时以内 新手友好度 95/100
-
难度 2/5 1-3 小时 新手友好度 65/100
syfoud/Simulated_Scepter#174 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
Giskard-AI/giskard-oss#2840 · 1 条评论 ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success 未关闭area: repo bug perceived difficulty: 2
难度 2/5 1-3 小时 新手友好度 70/100
-
难度 2/5 1-3 小时 新手友好度 75/100
yeti-platform/yeti#1380 ·