我想做这样的事情:
div#city{
background-image: url("{{ MEDIA_URL }}{{city.city_image}}");
}
如果我在HTML中添加上面的内联CSS,它确实产生了以下路径并且它渲染得很好但我无法从CSS访问它。
<div class="container" style="background-image:url('media/city_pictures/paris-france.jpg');">
<div class="city_header">
<h1> PARIS </h1>
</div>
</div>
我可以从CSS访问静态图像,但不能访问媒体图像。
答案 0 :(得分:0)
用户相对路径,例如:
switch(viewType)
{
case CATEGORY:
View headerView = LayoutInflater.from(parent.getContext()).inflate(R.layout.rootview_magazine_toc_tab, parent, false);
TOCHolder myHeaderViewHolder = new TOCHolder(headerView, viewType);
Log.d("CreateviewHolder", ""+CATEGORY);
return myHeaderViewHolder;
break;
case TYPE_ONE_AD:
View adView = LayoutInflater.from(parent.getContext()).inflate(R.layout.rootview_toc_ad_one, parent, false);
TOCHolder adViewHolder = new TOCHolder(adView, viewType);
Log.d("CreateviewHolder", ""+TYPE_ONE_AD);
return adViewHolder;
break;
case TYPE_TWO_AD:
View adView2 = LayoutInflater.from(parent.getContext()).inflate(R.layout.rootview_toc_ad_two, parent, false);
TOCHolder adViewHolder2 = new TOCHolder(adView2, viewType);
Log.d("CreateviewHolder", ""+TYPE_TWO_AD);
return adViewHolder2;
break;
case TYPE_THREE_AD:
View adView3 = LayoutInflater.from(parent.getContext()).inflate(R.layout.rootview_toc_ad_three, parent, false);
TOCHolder adViewHolder3 = new TOCHolder(adView3, viewType);
Log.d("CreateviewHolder", ""+TYPE_THREE_AD);
return adViewHolder3;
break;
}
上面的示例是媒体文件夹和您的css文件夹是否在同一文件夹中。