Is there a way to align the content of the info window in Google Maps to the center

Check out this Stackblitz where I am facing an alignment problem with a Google Maps info window. Despite removing the close button, the window's positioning seems skewed due to padding and/or margins on the right side.

I'm looking for ways to properly center the Bootstrap card inside this info window. Any suggestions?

Answer №1

The excess white space on the right side is a result of this specific styling:

<div class="gm-style-iw-d" style="overflow: scroll; max-height: 508px;">
                                  ^^^^^^^^^^^^^^^^

Essentially, this causes the browser to always show scrollbars, even if there's no content overflow.

To address this, you should switch it to overflow: auto:

:host ::ng-deep .gm-style-iw-d {
  overflow: auto !important;
}

Another issue arises here:

<div class="gm-style-iw gm-style-iw-c" style="padding-right: 0px; padding-bottom: 0px;
                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This snippet removes the right paddings. It's recommended to retain them as they were initially (12px):

:host ::ng-deep .gm-style-iw-c {
    padding-right: 12px !important;
    padding-bottom: 12px !important;
}

The final step involves removing the fixed width from your cards:

<div class="card" style="width: 18rem;">
                         ^^^^^^^^^^^^^
                         remove this

This change will allow the cards to default to 100% width.

Customized Stackblitz

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

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

Executing a function defined in a .ts file within HTML through a <script> tag

I am attempting to invoke a doThis() function from my HTML after it has been dynamically generated using a <script>. Since the script is loaded from an external URL, I need to include it using a variable in my .ts file. The script executes successfu ...

Tips for effectively utilizing vue-draggable (or Sortable JS) within a v-data-table using the powerful combination of Vuetify 2 and Vue JS 2

I'm currently experimenting with integrating vue-draggable into Vuetify's v-data-table based on the instructions provided in this article : https://medium.com/vuetify/drag-n-drop-in-vuetify-part-ii-2b07b4b27684 The article mentions : "The main o ...

What is the best way to replicate tags in selenium when an element has multiple class names?

Extracting information from a webpage where a significant amount of text was concealed behind the "see more" tab. Using selenium to click on all such buttons and then extracting data with beautifulsoup. However, some of these buttons have additional space ...

Tips for importing a .geojson document in TypeScript using webpack?

I am trying to extract data from a .geojson file but faced some challenges while attempting two different methods: const geojson = require('../../assets/mygeojson.geojson'); The first method resulted in an error message stating: Module parse f ...

What is the process by which Quora loads two distinct webpages using one URL?

Have you ever noticed that when you visit without a Quora account, you are directed to a login or sign up page? But if you do have an account and visit the same URL, you're taken straight to your personalized feed. How does Quora manage to display di ...

Update the progressBar state by leveraging React Context

I've been working on integrating React Context in a small example project. In one component, I have a Progress bar, and in another one, I have a Toggle context. Although I've successfully implemented the context without any errors, it seems that ...

Timer Does Not Appear to be Counting Down

I recently added a countdown clock to my website, but I'm having an issue with it not updating in real-time unless the page is refreshed. I'm not very familiar with javascript, so I found some code online and made some modifications myself to sui ...

Using jQuery: How to implement a callback function or restore functionality after removing a checkbox

Below is the HTML code I am working with: <div class="foo"> <label class="checkbox-wrapper"> One<input type="checkbox" value="1" /> </label> <label class="checkbox-wrapper"> Two<input type="checkbox" value ...

Is there a way to stop the page from scrolling once I reach the bottom of a specific div within it?

My webpage has multiple divs that share a similar structure: <div style="height:200px; overflow:auto;"> <div style="height:300px;"> <!--There is a lot of content here--> </div> </div> When the user hovers ove ...

How can you align half of a circle on the bottom-center of a rectangle in a responsive way?

I'm working on a design where I have a large div taking up the width and some of the height, with a smaller circle that needs to be positioned half at the bottom/center of this div and half right after it. Everything seems to work fine until I increas ...

Struggling to locate the earliest date within a nested array of objects

I have an array of objects nested inside another object. My goal is to identify the minimum date from the 'FromDate' property within the 'Market' objects. What would be the most effective method to achieve this when dealing with both si ...

Icon for local system displayed on browser tab

I am currently trying to set a Browser Tab icon for the local system, but it is not working. However, when using an HTTP static icon, it works perfectly. Can someone please help me understand what the issue might be? PAGE 1 : Icon Not Showing <link re ...

What are the steps to achieve such a design?

Can you show me how to create a single layout using HTML and CSS? I am struggling with splitting the screen properly. Could you provide a simple example, maybe on jsfiddle? https://i.stack.imgur.com/d2rbn.jpg Thank you in advance! EDIT: I have added a ...

Using AngularJS to transfer data from a datepicker to an ng-model

I am currently trying to figure out how to pass the date from a datetimepicker into the model. Unfortunately, I am facing some challenges with this process. I wish I could provide a demo of the issue on a fiddle, but I am unsure of how to do so due to the ...

Utilizing AJAX for XML data parsing

I need help with formatting XML data into a table. The code I've written isn't working as expected. The XML data is structured in branches, causing it to not display correctly. Can someone assist me in fixing this issue? <!DOCTYPE html> &l ...

What is the process of converting a byte array into a blob using JavaScript specifically for Angular?

When I receive an excel file from the backend as a byte array, my goal is to convert it into a blob and then save it as a file. Below is the code snippet that demonstrates how I achieve this: this.getFile().subscribe((response) => { const byteArra ...

Turn off and then reinstall Image when clicked

function show(){ alert("i am pixel"); } function disableImgClick(){ $(".Dicon").unbind('click'); } $(document).ready(function(){ $("#turnoff_btn").click(function (e){ e.preventDefault(); disableImgClick(); }); }); i have a group of ima ...

In ReactJS, the error message 'callback is not a function' is indicating a TypeError

I am unsure of the reason behind this response's body. "<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <script src="/charting_library/charting_library.m ...

Stop repeated form submissions in Angular using exhaust map

How can we best utilize exhaust Matp to prevent multiple submissions, particularly when a user is spamming the SAVE button? In the example provided in the code snippet below, how do we ensure that only one submission occurs at a time even if the user click ...

Accessing form objects in Typescript with AngularJS

I am currently working with AngularJS and Typescript. I have encountered an issue while trying to access the form object. Here is the HTML snippet: <form name="myForm" novalidate> <label>First Name</label> <input type="text" ...