datepicker in bootstrap 4 obscured by the div

I am currently utilizing Bootstrap datepicker v4. However, I am facing an issue where the datepicker view is getting hidden behind the 'map' div. I have attempted to solve this problem by adding overflow: visible, but unfortunately, it does not seem to be effective. Below is my code snippet:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.7.1/css/bootstrap-datepicker.min.css" rel="stylesheet"/>
    <link rel="stylesheet" href="./style.css">
    <div id="main">
            <nav class="navbar navbar-expand-sm bg-light navbar-dark">
                <div class="row">
                          <div class="col-md-4 columns"><a class="navbar-brand" href="">Crime Prediction</a></div>
                          <div class="col-md-1 columns">
                          </div>
                          <div class="col-md-2 columns">
                                <input data-date-format="dd/mm/yyyy" id="datepicker" class='bdate'>  
                          </div>
                          <div class="col-md-2 columns">
                          </div>
                          <div class="col-md-3 columns">
                          </div>
                </div>
            </nav>
            <div class="container-fluid">
              <div class="row">
                <div class="col-md-8 col-sm-12 map-block">
                    <div class="row">
                        <div class="col-sm-12">
                            <div id = "map" style="width:100%;height:100vh;">Hey</div>
                        </div>
                    </div>
                </div>
                <div class="col-md-4 col-sm-12 junk_charts" >
                    <div class="row">
                        <div class="col-sm-12" '> 
                        </div>
                    </div>
                </div>
            </div>
          </div>
    </div>

        <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.7.1/js/bootstrap-datepicker.min.js"></script>
    <script type="text/javascript">
        $(function() {
        $("#datepicker").datepicker({

        });
      });
    </script>

To create a dashboard view, I am using overflow:hidden in my parent div. Even though this is causing issues, it is necessary for my project. Are there any alternative solutions that can help me overcome this challenge? Here is a glance at my CSS:

    body {
  font-family: 'tahoma';
  font-size: 14px;
  overflow-y:hidden;

}

.navbar { padding: 0px 1rem;}
.navbar .navbar-brand {
  font-size: 14px;
  color:#000;
}

.navbar .row { width:100%; }
.navbar .row .columns { padding-top: 7px; }
.navbar .form-group { padding-bottom: 7px; margin-bottom: 0px; }
.navbar .form-group label { color: #000;}
.navbar .form-group select { padding: 3px; }
.map-block {padding-left:0px; padding-right:0px;}
.padd-top-20 { padding-top: 15px; }


.junk_charts {
  background-color: silver;
  position:relative;
  overflow: scroll;
    height: 700px;
}

Map code

    var map = L.map('map').setView([41.85, -87.6298], 11);

// load a tile layer
L.tileLayer('https://api.mapbox.com/styles/v1/kuhugupta/cjo4txr7o02i12rn8pr2x1cji/tiles/{z}/{x}/{y}?access_token=pk.eyJ1Ijoia3VodWd1cHRhIiwiYSI6ImNpcDgxYmg1YzAxN2hzem5yaXRtaDN6dWYifQ.hAIOSatYipnZ-NnqodCQFg',
  {
       attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>',
      maxZoom: 18,

      username: 'XXXXX',
      id: 'xxxxx',
      tileSize: 512,
      zoomOffset: -1,
    accessToken: 'xxxxx'

  }).addTo(map);

Answer №1

The map generated by the leaflet has a z-index of 999 and a zoom button with a z-index of 1000. The datetimepicker div that you generate (bottom div) has a default z-index of 1.

To ensure it appears on top of the map, simply add the following CSS code:

.datepicker {
  z-index: 1001 !important;
}

(The use of !important overrides any previously set CSS property)

Below is a working snippet example:

$(function() {
  $("#datepicker").datepicker({

  });
...
...
...
</script>

Answer №2

Include the "container=body" attribute in the date picker element

 <input container="body" data-date-format="dd/mm/yyyy" id="datepicker" class='bdate'>

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

Discovering specific values for an ID using API calls in Angular (Implementing CRUD Operations in Angular with API Integration)

My current project involves CRUD operations in Angular utilizing the API created in Laravel. I have successfully added and fetched values, but encountered an issue when attempting to update values using their respective IDs. This snippet is from my app.co ...

JavaScript error occurring when trying to validate Ajax response

I am attempting to create a report using a dynamically generated form. The form loads successfully through XMLHttpRequest, but the validation for the form fields does not seem to be working. I have experimented with using eval() and found that it only work ...

Resizing a column in the Bootstrap CSS grid causes adjacent columns to move

I am currently working with a bootstrap grid that includes an expand component. The issue I am facing is that when I expand one column, the other columns in the same row also shift. Is there a way to make each column independent of the others? expand co ...

Ways to extend div to fill the rest of the page's vertical space

Apologies, my search has yielded many results, but none that directly address my specific issue. It appears that there is a proliferation of div-height problems on this platform. :-( Here is the layout I am working with for testing purposes: <!DOCTYPE ...

Tips for including a lang attribute in HTML tags within Next.js

When I ran a performance check on my Next.js portfolio site, I discovered that the main index.html is missing a lang attribute. This absence results in a deduction from the accessibility score. I could add the locale by configuring i18n setup in the next. ...

What is the correct way to iterate through a list of images fetched with getStaticProps and display them within the same component?

What is the proper way to map a list of images returned using getStaticProps? I had successfully implemented this by passing a prop to the gallery component in another page. However, I now want to consolidate all the getStaticProps code within the gallery ...

Locate the initial anchor tag using PHP

Is there a way to extract and display only the first anchor tag using PHP from the given HTML string? <ul class="side-navigation"> <li><a href="/?id=12">What is RtII?</a></li> <li><a href="/?id=13">RtII in NY</ ...

In order for Angular jQuery click events to properly function, they must be triggered by a

My admin panel is built using jQuery and Bootstrap, and it functions properly when used outside of the Angular framework. However, after integrating jQuery and Bootstrap into an Angular project and configuring them, I noticed that I had to double click on ...

Update the CAPTCHA, while also refreshing the entire registration form

JavaScript Snippet <script language="javascript" type="text/javascript"> function updateCaptcha() { $("#captchaimage").attr('src','new_captcha_image.php'); } </script> New Image Code <img src="new_ ...

What is the best way to display ng-repeat elements in a horizontal layout

Looking for a way to display thumbnails horizontally using ng-repeat in AngularJS and Bootstrap. Any ideas on how to achieve this with CSS or Bootstrap? <div class="row"> <ul class="col-md-4" id="phones"> <li class="thumbnail" ...

CSS - Discovering the reason behind the movement of text post generation (animation)

I have a question regarding CSS animation, specifically the typewriting effect. I was able to successfully achieve the typewriting effect using animation. However, I noticed that even though I did not set any animation for transforming, once the text is g ...

Exploring the World of jQuery Caching and Navigating Through Objects

I'm interested in learning more about jQuery caching and how it can enhance performance. Can you explain how to properly utilize this technique? From what I understand, when using a jQuery selector, you're essentially searching the DOM to create ...

PHP POST data not displaying in output

Having an issue with displaying the chosen value from a database enum in a text field on my website. The enum table has options like Bachelor of Science, Master of Science, Bachelor of Education, and Master of Education. I want to show the selected option ...

Using Jquery to automatically adjust price based on selected options

Running an online retail store means you can offer products with different variables. For example: Colour: <select class="vars" name="size"> <option>Choose an option</option> <option data-price="-10.00" value="B">blue</o ...

Struggling to make addClass and removeClass function correctly for the development of the unique "15 puzzle" game

I am currently in the process of creating a version of "the 15 game" using jQuery in HTML. You can find more information about the game on this page. The objective of the game is to rearrange a table of "boxes" in ascending order from 1 to 15. Below is th ...

What could be causing my for loop to become unresponsive?

My for loop seems to be populating all fields with the last object parsed. http://codepen.io/anon/pen/EKxNaN This is my current code. I created something similar on CodePen since I can't access JSON from the original source there. var championMaste ...

Transmit an echo using AJAX

Apologies if this question has already been asked, I tried searching but couldn't find any answers (OR didn't understand the answer). I have a hyperlink and would like to retrieve the value using AJAX. Here is an example with PHP: HOME <a h ...

Retrieving location data using the Google Maps geocoder

Could someone help me with this issue in my code? function getLocationName(latitude, longitude) { if (isNaN(parseFloat(latitude)) || isNaN(parseFloat(longitude))) { return false; } var locationName; var geocoder = new google.maps. ...

Efficiently uploading multiple files using AJAX in conjunction with Codeigniter

Greetings! I'm attempting to utilize ajax and codeigniter to upload multiple images. As a beginner in ajax and jquery, I would greatly appreciate any assistance in identifying where I might be going wrong or missing something. Below is my controller ...

Turn an entire div into a clickable element with a functional :active CSS rule that is compatible with IE10

I am currently working on designing a clickable panel for an html app that will include multiple text elements and images. Based on my understanding, this is typically achieved using a div. An example of this would be: <div class="myButton"> &l ...