多个:在css中的伪元素之前或:之后

Bla*_* M. 1 html css

让我们说我有一个包含通知消息的div

<div class="notification"></div>
Run Code Online (Sandbox Code Playgroud)

消息是通过PHP动态生成的

<div class="notification><?php echo $notif;?></div>
Run Code Online (Sandbox Code Playgroud)

但我希望那个div说它持有通知

Notification: [notification message]
Run Code Online (Sandbox Code Playgroud)

所以我输入了css:

.notification:before{
    content:'Notification: ';
}
Run Code Online (Sandbox Code Playgroud)

问题是我可以为该div添加另一个内容.例如,我想在通知之前出现警告图片:

所以可以把另一个和之前

.notification:before{
     content:url(warning.png);
}
Run Code Online (Sandbox Code Playgroud)

如果我喜欢那最后一个来了.那么如何展示它们呢?

Lin*_*TED 5

您可以将图像设置为背景:before,如下所示:

.notification:before {
    content: 'Notification: ';
    padding-left: 20px;
    background: url('warning.png') left center no-repeat;
}
Run Code Online (Sandbox Code Playgroud)

JSFIDDLE DEMO