Ich benutze Angularjs, um einige Bilder im DOM anzuzeigen, und wenden Sie etwas Stil auf sie (dimmen Sie den Hintergrund). Es scheint, dass ich ng-style
nicht auf das img
-Tag anwenden kann. Was ist der Grund dafür?Angularjs - Kann nicht ng-style auf img-tag anwenden (mit ng-repeat)
Fiddle hier.
HTML:
<div ng-controller="MyController">
<div class="row">
<div class="col-md-4 col-lg-4 col-sm-12 postCon" ng-repeat="post in posts">
<div class="rel">
<img src="{{post.link}}" alt="..." class="img-thumbnail" ng-click="test()" ng-style="{'background':'linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url('+post.link+')','background-size': 'cover'}">
<li class="del">button</li><li class="getLink">get link</li>
</div>
</div>
</div>
</div>
CSS:
.del{
font-size: 15px;
color: black;
z-index: 10;
text-decoration: none;
padding: 5px 10px;
background-color: white;
position: absolute;
left: 0;
bottom: 0;
}
.getLink{
font-size: 15px;
color: black;
z-index: 10;
text-decoration: none;
padding: 5px 10px;
background-color: white;
position: absolute;
right: 0;
bottom: 0;
}
.rel{
position: relative;
height: auto;
width: auto;
display: inline-block;
}
bitte versuchen Sie es ng-Stil in Stil –
Es funktioniert nicht, die " Dim "Effekt wird nicht auf das Bild angewendet. – undroid
Warum hast du keine ng-Klasse verwendet? – abhaygarg12493