I'm struggling to understand why the background image is not showing up. However, when I use content:url()
, it does appear. The issue with using content:url()
is that I can't control the size of the image. Below, you will find the complete code for your reference.
Component
@Component({
selector: 'app-reset-password',
template: `
<form>
<h2 class="dialog-form-title">RESET PASSWORD</h2>
<div class="warning-messages"><span class="warning_image">This User ID will no longer be able to log in with their
previous password.</span></div>
<div class="dialog-form-footer" fxLayoutGap="20px">
<button mat-flat-button type="submit" [mat-dialog-close]="true" style="margin:5px;background:#2BA9F8;">Confirm</button>
<button mat-flat-button type="button" [mat-dialog-close]="false" style="margin:5px;background:#D3D3D3">Cancel</button>
</div>
</form>
`,
styles: ['.warning-messages{background-color: #FFFEEF; color: #D9B88A; padding: 20px 10px; margin-bottom: 10px; font-weight: 400; }.warning_image:before{background-image: url("https://cdn1.iconfinder.com/data/icons/crime-and-security-3-5/48/147-128.png");}.warning_image:before{display: inline-block;vertical-align: middle;background-size: 12px auto;}']
})
This DEMO showcases the functionality.