Skip to content
This repository has been archived by the owner on Mar 24, 2020. It is now read-only.

Can't Center Map #44

Open
eweisbrot opened this issue Nov 20, 2014 · 4 comments
Open

Can't Center Map #44

eweisbrot opened this issue Nov 20, 2014 · 4 comments

Comments

@eweisbrot
Copy link

Hello,

I'm attempting to center my map using a css centering class that works for text and images, but some reason isn't working on the map. I'm using: class="text-center".

Please see the page below:

http://199.119.123.135/surety-bonds/commercial-bonds/auto_dealer_bond_map.htm#requirements

Any ideas? Thanks!

@CaptainStack
Copy link

text-align: center only works on inline elements. This map is housed in a div which is a block element. You need to do this:

.text-center {
    margin-left: auto;
    margin-right: auto;
}

@eweisbrot
Copy link
Author

Thanks CaptainStack!

@kjrhody
Copy link

kjrhody commented Sep 22, 2016

The SVG also has a lot of extra whitespace on the right, so I did it this way to reduce that (if making the background a different color) as well as centering.

 #map {
      margin-left: auto;
      margin-right: auto;
      height: 40em;
      width: 80%;
  }
  svg {
      background-color: #fff;
      width:80%;
      margin: auto;
      display: block;
  }

@zabackka
Copy link

zabackka commented Oct 1, 2018

After creating the map object, set the viewBox attribute to "0 0 921.66444 291.33102"
This should trim all the unnecessary whitespace, although I haven't tested it with the state labels turned on.

$( "svg" ).attr("viewBox", "0 0 921.66444 291.33102");

Good luck!

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

No branches or pull requests

4 participants