简体   繁体   English

如何更改Google Places自动完成的字体大小和字体系列?

[英]How to Change Font Size & Font-Family of Google Places Autocomplete?

I'm currently trying to adjust the CSS attributes of the Google Places Autocomplete in the Javascript API. 我目前正在尝试在Javascript API中调整Google地方信息自动完成功能的CSS属性。 In this link here I can see that the CSS classes are listed by Google. 在这里的链接中我可以看到Google列出了CSS类。

自动完成字体

And I tried to edit the CSS directly in the HTML file: 我尝试直接在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>

Though that does not seem to be working. 虽然这似乎不起作用。 I looked at other StackOverflow posts and was unable to find a solution that works. 我查看了其他StackOverflow帖子,但找不到有效的解决方案。

This is what the HTML looks like: 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>

And also the Javascript 还有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());
    });
  }
}

Fixed! 固定! I had to go into the bootstrap css and change span { font-size: 50px; } 我必须进入引导CSS并更改span { font-size: 50px; } span { font-size: 50px; } to span { font-size: 12px; } span { font-size: 50px; } span { font-size: 12px; } span { font-size: 12px; }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM