.my-div:before {
content: url('/pathToMyImage/image.png.png');
position: absolute;
}
我使用的是Angular JS,图像应该是动态的。假设它的路径存储在$scope.path
变量中。
$scope.path="/pathToMyImage/image.png";
如何传递$scope.path
的值来动态设置内容?
设置$scope。
$scope.path="/pathToMyImage/image.png";
,然后在你的HTML文件中访问它,如下所示。
{{path}}//用于数据绑定
假设content.content_id
包含动态图像名称。那么路径就是
。<img src="https://s3.amazonaws.com/gicontent/345X195/{{content.content_id}}.png" />