如何更改字体大小& Google商家信息自动填充字体系列?

时间:2015-05-21 14:00:26

标签: javascript html css google-maps-api-3 google-places-api

我目前正在尝试在Javascript API中调整Google商家信息自动填充功能的CSS属性。在此链接here中,我可以看到Google列出了CSS类。

Autocomplete Font

我尝试直接在HTML文件中编辑CSS:

<style>
    .pac-item-query { font-size: 12px; }
    .pac-item { font-size: 12px; }
    .pac-item-container { font-size: 12px; }
    .pac-item-matched { font-size: 12px; }
</style>

虽然这似乎不起作用。我查看了其他StackOverflow帖子,但无法找到有效的解决方案。

这就是HTML的样子:

<body id="page-top" class="index" onload="initialize()">
<!-- Header -->
<header>
    <div class="container">
        <div class="intro-text">
            <a href="index.html">
                <div class="intro-lead-in">
                    <h3></h3></div>
            </a>
            <div class="form-group">
                <form method="link" action="results.html">
                    <table>
                        <col width="1000">
                        <col width="500">
                        <tr>
                            <div class="col-sm-11">
                                <td colspan="2">
                                    <h3 style="border-bottom: 2px solid white;"> Tell us about your move! </h3><br>
                                </td>
                            </div>
                        </tr>
                        <tr>
                            <div class="col-sm-11">
                                <td>
                                    <h4>Please enter your pick up address</h4><br>
                                </td>
                                <td>
                                    <input id="start" type="text" class="form-control" placeholder="85 Madeup Street, City, Zip Code, State" name="start"><img src="img/powered-by-google-on-non-white.png"/><br>
                                </td>
                            </div>
                        </tr>
                        <tr>
                            <div class="col-sm-11">
                                <td>
                                    <h4>Please enter your drop off address</h4><br>
                                </td>
                                <td>
                                    <input id="destination" type="text" class="form-control" placeholder="64 Madeup Street, City, Zip Code, State" name="dest"><br>
                                </td>
                            </div>
                        </tr>
                        <tr>
                            <div class="col-sm-11">
                                <td>
                                    <h4>Which type of vehicle will you need?</h4><br>
                                </td>
                                <td>
                                    <select id="mode" class="form-control" name="mode">>
                                        <option value="#" selected>Type of Vehicle</option>
                                        <option value="VAN">Van</option>
                                        <option value="SUV">SUV</option>
                                        <option value="TRUCK">Pick Up Truck</option>
                                        <option value="CAR">Car</option>
                                    </select><br>
                                </td>
                            </div>
                        </tr>
                        <tr>
                            <div class="col-sm-11">
                                <td colspan="2">
                                    <h3 style="border-bottom: 2px solid white;"> Enter Contact Information </h3><br>
                                </td>
                            </div>
                        </tr>
                        <tr>
                            <div class="col-sm-11">
                                <td>
                                    <h4>Please let us know your name</h4><br>
                                </td>
                                <td>
                                    <input id="name" type="text" class="form-control" placeholder=" e.g. John Johnson" name="name"><br>
                                </td>
                            </div>
                        </tr>
                        <tr>
                            <div class="col-sm-11">
                                <td>
                                    <h4>Please enter your phone number. We will notify you when your driver is on their way</h4> <br>
                                </td>
                                <td>
                                    <input id="phone" type="tel" class="form-control" name="phone" placeholder=" e.g. 781222777"><br>
                                </td>
                            </div>
                        </tr>
                        <tr>
                            <div class="col-sm-11">
                                <td>
                                    <h4>Please provide your email</h4><br>
                                </td>
                                <td>
                                    <input id="email" type="email" class="form-control" name="email" placeholder=" e.g. example@example.com"><br>
                                </td>
                            </div>
                        </tr>
                        <tr>
                            <div class="col-sm-11">
                                <td>
                                    <h4> Could you please describe the items you are moving and the quantity?</h4><br>
                                </td>
                                <td colspan="2">
                                    <textarea id="description" class="form-control" name="description" placeholder=" e.g. 1 large couch, 2 small lamps, and a fruit bowl."></textarea><br>
                                </td>
                            </div>
                        </tr>
                        <tr>
                            <td>
                                <h4></h4><br>
                            </td>
                            <td>
                                <select id="help" class="form-control" placeholder="">
                                    <option value="Yes" selected>Yes Please!</option>
                                    <option value="No" selected>No Thank You</option>
                                </select><br>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <input type="submit" class="page-scroll btn btn-xl" color="black" id="submit" onclick="saveData()">
                            </td>
                        </tr>
                    </table>
                </form>

            </div>
        </div>
    </div>
</header>

还有Javascript

// USES THE GOOGLE PLACES LIBRARY
// ==============================
// This example displays an address form, using the autocomplete feature
// of the Google Places API to help users fill in the information.

var placeSearch, autoCompleteOrigin, autoCompleteDest;
var componentForm = {
  street_number: 'short_name',
  route: 'long_name',
  locality: 'long_name',
  administrative_area_level_1: 'short_name',
  country: 'long_name',
  postal_code: 'short_name'
};

function initialize() {
  // Create the autocomplete object, restricting the search
  // to geographical location types.
  autoCompleteOrigin = new google.maps.places.Autocomplete(
      /** @type {HTMLInputElement} */(document.getElementById('start')),
      { types: ['geocode'] });
  autoCompleteDest = new google.maps.places.Autocomplete(
      /** @type {HTMLInputElement} */(document.getElementById('destination')),
      { types: ['geocode'] });
  // When the user selects an address from the dropdown,
  // populate the address fields in the form.
  google.maps.event.addListener(autoCompleteOrigin, 'place_changed', function() {
    fillInAddress();
  });
  google.maps.event.addListener(autoCompleteDest, 'place_changed', function() {
    fillInAddress();
  });
}

function fillInAddress() {
  // Get the place details from the autocomplete object.
  var place = autocomplete.getPlace();

  for (var component in componentForm) {
    document.getElementById(component).value = '';
    document.getElementById(component).disabled = false;
  }

  // Get each component of the address from the place details
  // and fill the corresponding field on the form.
  for (var i = 0; i < place.address_components.length; i++) {
    var addressType = place.address_components[i].types[0];
    if (componentForm[addressType]) {
      var val = place.address_components[i][componentForm[addressType]];
      document.getElementById(addressType).value = val;
    }
  }
}

// Bias the autocomplete object to the user's geographical location,
// as supplied by the browser's 'navigator.geolocation' object.
function geolocate() {
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position) {
      var geolocation = new google.maps.LatLng(
          position.coords.latitude, position.coords.longitude);
      var circle = new google.maps.Circle({
        center: geolocation,
        radius: position.coords.accuracy
      });
      autocomplete.setBounds(circle.getBounds());
    });
  }
}

1 个答案:

答案 0 :(得分:0)

固定!我必须进入bootstrap css并将span { font-size: 50px; }更改为span { font-size: 12px; }