2017-06-06 61 views
0

我加入到我的網站谷歌的地方自動完成框。樣式表不適用於HTML嗎?

#pac-card.pac-card 
    div 
    #pac-title 
     | Autocomplete search 
    #type-selector.pac-controls 
     input#changetype-all(type='radio', name='type', checked='checked') 
     label(for='changetype-all') All 
     input#changetype-establishment(type='radio', name='type') 
     label(for='changetype-establishment') Establishments 
     input#changetype-address(type='radio', name='type') 
     label(for='changetype-address') Addresses 
     input#changetype-geocode(type='radio', name='type') 
     label(for='changetype-geocode') Geocodes 
    #strict-bounds-selector.pac-controls 
     input#use-strict-bounds(type='checkbox', value='') 
     label(for='use-strict-bounds') Strict Bounds 
    #pac-container 
    input#pac-input(type='text', placeholder='Enter a location') 

,並有一個樣式定義:

.pac-card { 
    margin: 10px 10px 0 0; 
    border-radius: 2px 0 0 2px; 
    box-sizing: border-box; 
    -moz-box-sizing: border-box; 
} 

#pac-container { 
    padding-bottom: 12px; 
 margin-right: 12px; 
} 

我做包括頁面上的樣式表。樣式表不適用於HTML可能是什麼原因?

的代碼是正確的,因爲我嘗試了一下上的jsfiddle。

+0

的是,在[哈巴狗(https://github.com/pugjs/pug)? –

+0

@PatrickRoberts,是啊。無論如何,該CSS不會對DOM做很多改變。你有沒有(@ konyv12)試圖添加其他CSS的東西來顯示明顯的變化? – Wax

回答

2

你的代碼是不是HTML(也許這生成HTML模板代碼?)。 我接過來一看一個地方自動填充文件(https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete?hl=fr)和HTML應該看起來像:

<input id="pac-input" class="controls" type="text" 
     placeholder="Enter a location"> 
    <div id="type-selector" class="controls"> 
     <input type="radio" name="type" id="changetype-all" checked="checked"> 
     <label for="changetype-all">All</label> 

     <input type="radio" name="type" id="changetype-establishment"> 
     <label for="changetype-establishment">Establishments</label> 

     <input type="radio" name="type" id="changetype-address"> 
     <label for="changetype-address">Addresses</label> 

     <input type="radio" name="type" id="changetype-geocode"> 
     <label for="changetype-geocode">Geocodes</label> 
    </div> 
    <div id="map"></div> 

在此代碼示例中,我看不到任何一個DIV#PAC-容器ID。

所以第一件事情,請確保您生成的HTML具有與您的樣式正確的CSS選擇器。

+0

謝謝,爲我工作 – konyv12