我使用:: before或:: after插入图片。 CSS中的代码如下:
p::before {
content: url(../image/xs.jpg);
}
或
p::after {
content: url(../image/submit.png);
}
[当我检查:: before或:: after的宽度时,内容框的宽度与图片的宽度相同。但是,内容框的高度是自动设置的,并且低于图片的高度。我试图像这样指定高度:
p::before {
height: 37px;
}
或
p::before {
height: 71px;
}
它不起作用。都不会溢出。在这种情况下,有什么方法可以指定高度吗?
使用背景图像
.image:before {
content:"";
display:block;
background-image: url(https://via.placeholder.com/150);
height: 150px;
width: 150px;
}