css - 如何为在传单地图上用作标记的 div 指定灵活宽度?
问题描述
我有一个文本字段,我想扩大它的宽度以适应内容,但最多只能达到一定宽度(200px)的宽度 - 任何更宽的东西都应该换行到下一行。
我目前正在使用以下 HTML 执行此操作:
<div class="wrapper">
<div class="info">Any long text can go in here to test what goes wrong with wrapping.</div>
</div>
和 CSS:
.wrapper {
position: relative;
display: run-in;
}
.info {
position: absolute;
max-width: 200px;
}
这本身就可以正常工作。但是当我将它用于 Leaflet 标记的 HTML 时,如下所示,
L.marker(
[ myLat, myLong ],
{icon: L.divIcon({
className: 'my-div-icon',
html:'<div class=wrapper><div class=label>'+innerText+'</div></div>'}) }
).addTo(layerGroup);
结果是错误的 - 它在每个空格之后换行。据我所知,这似乎是L.icon
属性iconSize
默认为 null 的结果,因此零成为<div>
. 但是,如果我手动强制iconSize
设置一个更大的数字(200 像素),那么即使<div>
预期的内容(innerText
如何使 Leaflet 标记适合innerText
<200px 的宽度,但如果宽度更宽,则以 200px 换行?
解决方案
推荐阅读
- json - 预期对象或值:将 JSON 导入 Python (Pandas)
- azure-service-fabric - 如何在 Azure Service Fabric 容器中通过 Traefk 启用前端 HTTPS
- vba - 在 Access 中选中和取消选中复选框
- c# - 为什么我的 ODataACtionParameters 对于 POST 请求为空?
- erlang - erlang 客户端和 seagull 服务器之间的能力交换失败
- angular - 如何使用 IdentityServer4 为 Angular 应用程序实现隐式流程
- java - 如何创建n个数字的递归平方和方法?
- php - PhpSpreadsheet 将单元格的背景颜色设置为白色
- php - laravel 迁移 SQLSTATE[HY000]:一般错误:1215 无法添加外键约束
- c++ - c ++ ecliipse free():函数末尾的无效指针