2013-05-11 40 views
1

我有以下腳本:流失風格

$('#Entity_Wall').typeahead({ 
     name: 'walls', 
     remote: "http://localhost/getsomestuff?text=%QUERY', 
     limit: 10, 
     template: '{{value}}<div class="template-wall-front-farthest" 
      style="background:url(\'{{image}}\');</div>', 
     engine: Hogan 
    }); 

我有以下樣式:

.template-wall-front-farthest { 
     float: left; 
     margin-right: 5px; 
     background-position: -132px -2px; 
     width: 16px; 
     height: 19px; 
     background-repeat: no-repeat; 
    } 

當應用我typahead模板,我的背景圖像未被正確定位。它漂浮在左邊,並具有正確的尺寸,只是錯誤的位置。爲了得到它的工作我要修改我的模板:

template: '{{value}}<div class="template-wall-front-farthest" 
    style="background:url(\'{{image}}\');background-position: -132px -2px;"></div>' 

有什麼辦法我可以利用我的css樣式,而不是直接將這個我的模板?

+0

你可以試試:'背景位置:-132px -2px重要;'但是我不知道它如果還有更好的辦法 – Romoku 2013-05-12 02:51:55

+0

@三國好主意!不幸的是它沒有奏效。 – mattruma 2013-05-12 10:12:56

回答

0

想通了......剛剛更換backgroundbackground-image,如下:

template: '{{value}}<div class="template-wall-dropdown" 
      style="background-image:url(\'{{image}}\');"></div>'