mirror of
https://gitlab.com/mrubli/hugo-mod-leaflet.git
synced 2025-10-07 01:54:24 +00:00
static: css: Fix map tile offset for maps with Tailwind Typography
Embedding a Leaflet map within a Tailwind Typography-styled <article> leads to a very subtle (the higher the zoom the subtler) vertical map offset. It is particularly noticeable in combination with track overlays where tracks and map are suddenly misaligned. The root cause is this part of the Tailwind-generated stylesheet: .prose :where(img):not(:where([class~=not-prose],[class~=not-prose] *)) { margin-top: 2em; margin-bottom: 2em } It adds a 2em margin to all <img> element and, because Leaflet tiles are images, that leads to a vertical offset. The obvious solution is to not embed maps in a <article class="prose">. Another workaround is to add a "not-prose" class to the map container: <div id="map_container" class="not-prose">…</div> While the above should reliably prevent any other Tailwind shenanigans, forcing the <img> margin to be zero should work well enough for now.
This commit is contained in:
@@ -23,6 +23,13 @@
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
/* Prevent styling from accidentally adding a margin to <img> elements. Leaflet tiles are such
|
||||
elements and adding a margin creates a hard-to-notice and hard-to-debug offset in map tiles.
|
||||
This problem has been observed when embedding maps within a @tailwindcss/typography <article>. */
|
||||
.map-container img {
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
/* Heightgraph grid lines */
|
||||
.map .heightgraph .grid .tick line {
|
||||
stroke: #ccc;
|
||||
|
Reference in New Issue
Block a user