流失风格

问题描述:

我有以下脚本:流失风格

$('#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

想通了......刚刚更换backgroundbackground-image,如下:

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