Google maps not functioning properly with fixed position

Having trouble with including Google Maps within my webpage. I want it to be fixed in place as I have a long list on the left of the map. However, when I add position: fixed; to the map's CSS, it stops scrolling and just shows a white area underneath:

https://i.sstatic.net/Vo599.png

Below is the CSS for the left list and the map on the right:

.grid-container {
    display: grid;
    grid-template-columns: 480px 1fr;
    grid-template-rows: 1fr;
    grid-template-areas: "list map";
  }

.list {
    grid-area: list;
    height: 100vh;
}

#map { 
    grid-area: map;
    position: fixed;
}

body {
    margin: 0;
}

HTML structure:

<body onload="initialize()">
   <form id="form1" runat="server">

   <div class="grid-container">

   <div class="list">
   <div class="navigation-bar"></div>

   <div class="tiles"></div>
   </div>

   <div id="map"></div>

  </div>
 </form>
</body>

I've tried multiple solutions from Stack Overflow but nothing seems to work. Any suggestions on how to resolve this issue would be greatly appreciated. Thank you!

Answer №1

#location { 
    grid-template: location;
    position: sticky;
    top: 0;
} 

This should solve the issue

For a more in-depth explanation, take a look at this resource https://example.com/csspositionsticky

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

html navigation bar is not functioning as intended in my webpage

I'm facing an issue with my navbar menu. I implemented some JavaScript code to make the navbar sticky while the user scrolls, but it's not working as expected. The navbar is not staying sticky when the page is scrolled. Could someone please revi ...

Accessing .js and .css libraries from shared views in ASP.NET Core can be restricted

I am currently developing a simple application on ASP.NET core 3.1, and I'm facing a basic problem that I can't seem to solve. The menu of the application is located in a Shared view called _Layout.cshtml. I load .js and .css libraries in this v ...

Step-by-Step Guide: Uploading Multiple Images with Links to a MySQL Database

My current code is functioning perfectly for single image uploads. However, I now have the requirement to upload multiple images simultaneously with the same Image Title and Image Description for each group of images. These images will be used in a photo s ...

Strange occurrence with getBoundingClientRect() function and F5 refresh, what could be causing this odd behavior?

Apologies for the lengthy code, I have stripped it down multiple times to make it stand-alone. Codepen won't be helpful in this case. You can simply copy and paste the code into an HTML file to see how it behaves. <!DOCTYPE html> <html> &l ...

Challenges with Hangman in JavaScript

As a beginner in JavaScript, I recently developed a simple hangman-like game. However, I encountered some challenges that I need help with. One issue is related to my lettersGuessed array. Currently, the array displays every time a key is pressed and repea ...

Why won't the sound play on the button with the picture?

I am currently working on a website project that requires buttons with pictures and sound. Despite my efforts, the sound feature is not functioning properly in Chrome and Firefox. I am still learning and would like to know how to toggle the sound on and of ...

designing a responsive form in the mobile environment

I have implemented a search form on my website with a button inside the text box. It works fine on desktop, but when I switch to mobile view, the positioning is off. I am currently using absolute positioning for the button to give it a fixed position. Is t ...

Tips for keeping elements in a table cell from overflowing onto multiple lines

Here is the structure I am working with: <table> <tr> <td> <div> <input type="text" placeholder="Enter your name""/> <input type="button" value ="save"/> </div> </td> ...

Is there a way to retrieve the central anchor point position (x, y) of the user's selection in relation to the document or window?

Is there a way to retrieve the center anchor point position (x, y) of the user's selection relative to the document or window? I have tried using window.getSelection() to get selected nodes, but I am unsure how to obtain their position: See an examp ...

Use jQuery to dynamically alter color based on conditional statements

What could be causing the background color not to change to green? var id; id = setInterval(changeColor, 1000); function changeColor(){ var elem= $("#target"); var color = elem.css('background-color'); if (color == &apos ...

Modifying the position of an HTML element within its parent tag using document.createElement

As I dive into learning Javascript, I've come across document.createElement. This method allows me to create an HTML tag and insert it into an existing HTML parent element. However, I have a specific question in mind: Is it possible to choose the exac ...

How can we avoid repeated evaluations by using memoization in a function?

Currently, I am working on a jQuery function designed to switch HTML elements based on specific viewports. The concept is quite simple: <div data-swap-for="#element" data-swap-on="phone"></div> This code snippet will insert the element with t ...

The CSS Scroll-Snapping feature seems to be overlooking one specific element that it should be snapping to

Currently, this website is designed to work exclusively for mobile devices. When viewed in Chrome's mobile view using the inspector, everything appears to be functioning correctly. However, when accessed through Safari or on an actual mobile phone, th ...

Placing <object> within the existing HTML form

If a user enters the values 12345 into an input box on my webpage and clicks a button, an object will appear below or instead of the form. The code I have for this functionality is: <form name="form" action="" method="post"> <input type="text" ...

What is the best way to locate and extract the content of an HTML element using XPath in Selenium with VBA?

I am currently seeking a solution to extract the content of an element with the name "data-testid" from a website. This specific element appears approximately 35 times within various contexts in the HTML code. The particular element I am interested in look ...

Positioning a Bootstrap popover directly adjacent to the cursor's location (within the clicked element)

I've been struggling to get my bootstrap popover to show up inside the element I'm calling it on, next to my mouse cursor. Despite extensive research in the popper.js documentation and numerous attempts with various parameters, including the &apo ...

Creating a Rectangle Overlay Effect on an Image using HTML/CSS

I have a React App where I am displaying live updates on NFL games. I want to overlay a football field image with a dynamic rectangle SVG element that represents the distance covered by the team in yards, while the remaining distance is left uncovered. Thi ...

Tips for organizing a div into a dock panel

I am seeking guidance on how to align and resize the following divs based on my specific requirements outlined below. Area A Area A should remain at the top with a set height that will not change. Area B The height of Area B should vary between 0 and a m ...

SVG Sprite remains functional even after deleting the element

Within my index.shtml, I include the following code: <object data="icons/svg-sprite.svg" type="image/svg+xml" width="0" height="0" style="display: none;"></object> Inside my svg-sprite.svg file ...

Clicking to close tabs

I am currently working on implementing a tab functionality on my website and I want these tabs to be responsive. Here is the code snippet I have been using: function openCity(evt, cityName) { var i, tabcontent, tablinks; tabcontent = document.ge ...