1
我似乎无法在使用ng样式设置背景图像后,将CSS样式应用于元素。在angularjs中添加背景图像,css无法正常工作
HTML:
<body id="bg" ng-controller="BgImagesListController" ng-style="selBGImg">
CSS:
#bg {
background: center center fixed transparent;
-webkit-background-size: contain;
-moz-background-size: contain;
-o-background-size: contain;
background-size:contain;
}
JS:
var mlwcApp = angular.module('mlwcApp', [])
.controller('BgImagesListController', function($scope, $http) {
$scope.selBGImg = {
background : 'url(bgimgs/bg.jpg)'
};
});
我用来设置背景图片在CSS和它的工作。使用ng样式后,图像可以显示,但所有其他样式都消失了。任何想法?
它的工作原理!谢谢,但为什么background-image在这里工作? –
,因为你重写了背景属性,在这里你只改变背景图像。 – vivid
我现在明白了,再次感谢您! –