Css 图像和文本作为内容属性的值

Css 图像和文本作为内容属性的值,css,Css,我使用content:属性为伪元素提供内容 我知道我可以用内容给它一个图像值:url(image.svg)和包含内容的文本:“你好”`,但是我如何给出一个图像和一个文本值呢。显示文本左侧的图像?使用:after和:before添加图像和文本 请看以下代码: 对于以后寻找解决方案的任何人,只需在before::pseudo元素的内容中添加url()和“String”,中间加一个空格 a::before{ 内容:url(“https://mozorg.cdn.mozilla.net/media/

我使用
content:
属性为伪元素提供内容


我知道我可以用
内容给它一个图像值:url(image.svg)和包含内容的文本:“你好”`,但是我如何给出一个图像和一个文本值呢。显示文本左侧的图像?

使用
:after
:before
添加图像和文本

请看以下代码:


对于以后寻找解决方案的任何人,只需在before::pseudo元素的内容中添加url()和“String”,中间加一个空格

a::before{
内容:url(“https://mozorg.cdn.mozilla.net/media/img/favicon.ico“”“图标后的额外文本:”;
}

对于图像使用
:before
,对于文本使用CSS使用
:before
?您是否尝试过类似.myImg:after{content:“Hello”}.myImg{content:url(image.svg);}@Oxymoron内容对实际元素不起作用。
div{
    background:#999;
    width:100px;
    height:50px;
    position:relative;
}
div:after{
    content:"Text is here";
    background:#ddd;
    position:absolute;
    height:20px;
    width:100px;
    bottom:-20px;
    right:-20px;
}
div:before{
    content:url(http://lorempixel.com/20/20);
    background:#ddd;
    position:absolute;
    height:20px;
    width:20px;
    bottom:-20px;
    left:0px;
}