Adjust the display size of the Cesium viewer

Currently in the process of developing a Webapp utilizing Cesium and Bootstrap.

The issue at hand is that the Cesium viewer does not seem to be resizable. The only solution I have come across is using overflow: hidden; in the CSS to limit it to 50% of the window size. However, this workaround can result in unnecessary resource consumption as we are essentially applying a band-aid fix.

Does anyone have any suggestions on how to resize the Cesium viewer without resorting to such measures?

  var cesiumContainer = document.getElementById("cesiumContainer");

  var ellipsoid = Cesium.Ellipsoid.WGS84;

  var viewer = new Cesium.Viewer("cesiumContainer", {
    sceneMode: Cesium.SceneMode.SCENE3D,
    infoBox: false,
    geocoder: false,
    timeline: false,
    animation: false,
    homeButton: false,
    scene3DOnly: true,
    baseLayerPicker: false,
    sceneModePicker: false,
    fullscreenButton: false,
    projectionPicker: false,
    selectionIndicator: false,
    navigationHelpButton: false,
    navigationInstructionsInitiallyVisible: false
  });
html,
body,
#cesiumContainer {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!DOCTYPE html>
<html lang='en'>

  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" href="http://cesiumjs.org/releases/1.11/Build/Cesium/Widgets/widgets.css">

    <script src="http://cesiumjs.org/releases/1.11/Build/Cesium/Cesium.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

  </head>

  <body>

    <div class="container-fluid">
      <div id="cesiumContainer"></div>

      <div class="col">
        This section must occupy 50% of the total height.
      </div>

    </div>

  </body>

</html>

Answer №1

Creating Responsive DIVs in CesiumViewer [CesiumJS]

In a previous discussion, I mentioned that with ReactJS, you have the capability to utilize Cesium as a react component and adjust the size of the Cesium map based on the browser dimensions.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for arranging Bootstrap thumbnails in a horizontal row

Could someone assist me with arranging Bootstrap thumbnails side by side instead of vertically stacked? Any advice is appreciated! Here is the current code snippet for the two thumbnails: <div class="row"> <div class="col-sm-6 col-md-4"& ...

Adjusting element position while scrolling

Objective The goal is to have the page navigation display lower on the page by default. This will provide a cleaner layout as shown in the image below. Context An interactive element for navigation was implemented utilizing Headroom.js. This library d ...

Can anyone recommend a high-quality jQuery lightbox replica?

Key Features Needed: Customizable with CSS Capable of handling forms, not just images Extensively documented Please provide any recommendations and suggestions for suitable options. Thank you in advance ...

varied arrangement and text size across various browsers

.header{ z-index:3; position:fixed; width:100%; height:10%; top:0px; background-color: white; } .header .header-bg { background-color: rgba(248,221,225,0.7); display:table; margin:auto; height:30px; width:30%; } .header .title-center{ text-decoration: un ...

The dropdown submenu in IE10 disappears prematurely, making it difficult to hover over the submenu

One of my clients is experiencing an issue with the navigation menu drop-down on their site at . While it works fine on all browsers, there seems to be a problem with hovering over submenus in IE 10 - they disappear too quickly. The client is using the SR ...

Tips for implementing z-index property on table border

I am encountering an issue with an html file that contains a table. The table has one row element with the css property of position: sticky, while the other rows are just example rows with "some text" in each cell. Within column 5 of the regular rows, I h ...

the new adjustment has not taken effect on index.php

I have been working on my index.php file and have included various other files as well. Let me show you the structure: <!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href="style.css" /> <style type= ...

What are the best methods for preserving paint color when changing wheel styles, and vice versa?

I posted this query about a year ago, but I did not have a fiddle prepared at that time and my question was not as well articulated as it could have been. Despite that, many people came forward to offer their help, and I am truly grateful for that. This ti ...

Preventing space reservation in vue transition-group for both elements during mode=out-in

Is there a way to ensure that the entering element is not displayed until after the leaving element has completely disappeared? I'm facing an issue where the container needs to expand in height to accommodate both elements at once. However, I have cho ...

The true height is never fully accurate when a vertical scrollbar is visible

Having an issue that needs solving. I've created a simple layout, but I'm struggling with getting the sidebar and wrapper to adjust their height properly. This is how the layout looks: <div class="sidebar collapse"> <div class="sideb ...

Correcting CSS to ensure alignment of container-fluid container

Having trouble aligning the login box to the center of the page. Any suggestions on how to achieve this? https://i.sstatic.net/3AFoL.png The following code attempts to achieve center alignment using Bootstrap 4.x base_nologin.html <!DOCTYPE html> ...

What is the best way to incorporate an image zoom-in effect into a flexible-sized block?

Having a fluid grid with 3 blocks in one row, each set to width:33.3%. The images within these blocks are set to width: 100% and height: auto. I am looking to implement a zoom-in effect on hover for these images without changing the height of the blocks. I ...

Troubleshooting issue with CSS `gap` property malfunctioning in conjunction with `display: block;` setting

I've run into an issue with the gap property in CSS not working as expected in my layout. After investigating, I found that some of my containers have display: block; set, which seems to be causing the gap property to be ineffective. My goal is to cre ...

When an HTML table utilizes both rowspan and colspan attributes, it may encounter issues with being overlapped by the

I'm working on a straightforward table that showcases the properties of a data element. Each row will represent an element from the AJAX response in a list format. The table is designed with "rowspan" and "colspan" to expand specific cells. However, ...

Adjust the z-index of elements by clicking on a different element

Thank you in advance for any help or advice, and please excuse my imperfect English :) I currently have an HTML element like this: <a id="menu-click" onclick="$('#menu-left').slideToggle('fast');return false;"></a> Clicki ...

Trigger a click based on the CSS path starting from a specific element in the DOM

I am currently developing a feature for mouse activities, such as moving the mouse, clicking, and scrolling. I want to be able to record these activities and then playback them later on. So far, I have successfully recorded mouse movement, and now I need t ...

Steps to insert a logo into a Bootstrap navbar

Hey there, I'm having trouble fitting my logo into a Bootstrap navbar. The issue is that the logo appears larger than the navbar itself, and I've tried various solutions without success. Can someone please assist me with this problem? Below is th ...

Would it be beneficial to assign a single class name to all elements with matching styles within a CSS framework?

Currently, I am in the process of creating my own CSS library or framework. However, I have encountered an issue where all 10 li tags share the same classes, such as .pl{ padding-left:10px} .mr{ margin-right:10px}, along with other necessary attributes. Wh ...

Tips for making items move to the next line after floats

Here is the code snippet I'm working with: <div>First</div> <div class="second">Second</div> <a>Alink</a> div{ display: block; float:left; } .second{ clear:right; } http://jsfiddle.net/cg4gj/ I am ...

How to ensure an image or ad stays in a fixed position on the screen

Is there a way to keep a part of the screen fixed, regardless of what other elements are in that space? Do I need to merge code with the HTML code of the ad or image to achieve this? ...