html - Flexbox 布局中的传单 map

标签 html css leaflet flexbox

我似乎无法(非常简单)Leaflet.mapflexbox 中呈现。我认为这可能是 invalidateSize

的问题

简单(损坏)示例: jsbin
如果您删除 flexbox CSS,它将起作用: jsbin

HTML

<body>
    <div id="content">
      <div id="mapPane"></div>
    </div>
</body>

CSS

body {
    display: flex;
    flex-flow: column wrap;
}

#content {
    flex: 1 1;
    order: 2;
}

#mapPane {
    height: 100%;
}

最佳答案

Flex 的力量现在拥有您

map Pane 没有继承的高度,因为父 #content 从其 Flex 属性获取高度(告诉它增长)。 #mapPane 因此具有正确的高度 — 0 的 100% 是 0

将 map Pane 带入 Flex 世界

  • display: flex 添加到#content。它仍然会随着现有的 flex: 1 属性增长:

    #content {
        display: flex;
    }
    
  • flex: 1 添加到 #mapPane:

    #mapPane {
        flex: 1;        
    }
    

完整示例

$(function() {
  L.map("mapPane");
});
html,
body {
  margin: 0px;
  height: 100%;
}
body {
  display: flex;
  flex-flow: column wrap;
}
#content {
  flex: 1 1;
  order: 2;
  display: flex;
}
#mapPane {
  flex: 1;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.1/leaflet.css" rel="stylesheet" type="text/css">
<script
  src="https://code.jquery.com/jquery-2.2.4.min.js"
  integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="
  crossorigin="anonymous"></script><script>L_PREFER_CANVAS = true;</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.1/leaflet-src.js"></script>

  <div id="content">
    <div id="mapPane"></div>
  </div>

关于html - Flexbox 布局中的传单 map ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27240894/

相关文章:

javascript - Vuejs 2.0 单文件组件、webpack 和 leaflet map

css - 更改 map 图 block 中的字体

html - Bootstrap 3 : Add Buttongroup to navbar

html - 将 zurb foundation 中的输入控件对齐在同一行

jquery - 单击链接并调整位置时显示弹出窗口

javascript - 如何从嵌套对象访问数据,然后在用户从下拉列表中选择选项后传递到 href 属性

html - 从 Swift 中的 html 字符串中删除空的 <p></p> 标签

javascript - 为什么固定 block 在滚动时闪烁?

html - 我们可以在 CSS 中指定自定义数据属性值吗?

r - 传单 R 中具有不同形状和颜色的自定义标记