HTML5 / Cesium - creating divs floats a cesium map

I use cesium: http://cesiumjs.org/ and I wanted some divs to float on the cesium map, but I can't get it to work.

I tried the following container / tag method in jsfiddle.net/j08691/dChUR/5/- replaced the image with a cesium map div card, but it doesn't seem to work - the tag div is not showing.

Any help?

+4
source share
2 answers

You need to add position: absolute;and topor bottomto your CSS, because the widget also uses absolute positioning. Adding this creates a new stack context that overrides z-index.

, " " :

Cesium.Camera.DEFAULT_VIEW_FACTOR = 0;

var viewer = new Cesium.Viewer('cesiumContainer', {
  timeline: false,
  animation: false,
  navigationHelpButton: false
});

var skyAtmosphere = viewer.scene.skyAtmosphere;
var skyCheckbox = document.getElementById('skyCheckbox');

skyCheckbox.addEventListener('change', function() {
  viewer.scene.skyAtmosphere = skyCheckbox.checked ? skyAtmosphere : undefined;
}, false);
html, body, #cesiumContainer {
  width: 100%; height: 100%; margin: 0; padding: 0; overflow: hidden;
  font-family: sans-serif; color: #edffff;
}
#controlPanel {
  position: absolute;
  top: 5px;
  left: 5px;
  background: rgba(42, 42, 42, 0.8);
  padding: 5px 8px;
  border-radius: 5px;
}
label {
  cursor: pointer;
}
label:hover span {
  text-decoration: underline;
}
<link href="http://cesiumjs.org/releases/1.15/Build/Cesium/Widgets/widgets.css" 
      rel="stylesheet"/>
<script src="http://cesiumjs.org/releases/1.15/Build/Cesium/Cesium.js">
</script>
<div id="cesiumContainer"></div>
<div id="controlPanel">
  This is a floating control panel<br/>
  with a translucent background color.
  <p>
    <label>
      <input id="skyCheckbox" type="checkbox" checked />
      <span>Enable atmospheric effect</span>
    </label><br/>
    <button class="cesium-button">Button 1</button>
    <button class="cesium-button">Button 2</button>
  </p>
</div>
Hide result
0

emackey , position: absolute css, top:150px bottom:150px. , .

, , , , 100% .

+2

Source: https://habr.com/ru/post/1544482/


All Articles