Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making width 100% so it fills space in responsive screen size #77

Open
ejntaylor opened this issue May 14, 2020 · 1 comment
Open

Making width 100% so it fills space in responsive screen size #77

ejntaylor opened this issue May 14, 2020 · 1 comment

Comments

@ejntaylor
Copy link

ejntaylor commented May 14, 2020

On smaller screens the container increases in size, but the map does not.

It seems the map canvas width and height is generated and injected into the dom element.

eg.
<canvas class="mapboxgl-canvas" tabindex="0" aria-label="Map" width="400" height="257" style="width: 400px; height: 257px;"></canvas>

I am unable to override the width with css.

Any ideas how I can make the map canvas expand to fill the parent container.

Thanks

@sdrios
Copy link

sdrios commented Mar 7, 2022

You can select the canvas element inside the map container and set it to width:100%;.

Here is an example with less
#map { width: 100%; height: 88vh; canvas { height: 100%; width: 100%; } }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants