Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Adding a margin to a google map

Featured Replies

I'm still learning HTML and CSS but I have improved a lot in the past couple of days. Still struggling with this though I have tried lots of different ways and none of them have worked.

 

See the screenshot below. Any idea how I could add a margin to the left of the map so that it is aligned with the text above? I'm pretty certain it is possible.

 

Alex.

 

 

Hey Alex

 

Have you tried to wrap the Map inside of a div? then position that div using margin: auto; or margin-left in the css?

 

Lewi

  • Author

I have tried this but it confuses me as the map is a script so I wouldn't be too sure where to place the element in the document. Would the css be added as an attribute or an element?

Hey

 

I'd probalys go for an element, i'll show you what i would do.

 

<div id="map">
    <script>google map thing</script>
</div>

 

#map {
width: xx px;
height: xx px;
margin-left: 5px;
}

 

i'd go for something like that to postion the map on the page.

 

Lewi

  • Author

That was very similar to what I had tried earlier except I just realised I had put the closing division tag in the wrong place. Unfortunately this still hasn't worked. Where would you place the following?

 

#map {

width: xx px;

height: xx px;

margin-left: 5px;

}

 

I have put it in the head of the document not sure if that is correct though.

 

Alex.

If you have a stylesheet you want to place it in their and remeber to change the xx in width and height to the width and height of your map

 

Lewi

  • Author

See that's probably my problem as I am new I didn't want the fuss of using a style sheet so I've been working in the html document itself. No reason why it shouldn't work still though. I'll keep trying thanks anyway.

Ah thats fine, but once you get more confident it's good to use one and it makes it more easier to build i found! if so just try placing this code inside the of the head tags inside.

 

<style type="text/css">
#map {
width: xx px;
height: xx px;
margin-left: 5px;
}
</style>

  • Author

I managed to get the first one you gave me working. At first I couldn't find the correct width and height of the map but instead I just used 100% for both which worked out fine and now my map has a nice 15px margin ha. :D

 

Thank you Lewis.

Glad to hear you've got it working! Just keep learning and picking up tips and most stuff will come to you easy

 

All the best

 

Lewi

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.