Mac*_*Tan 3 html css frontend sass pseudo-element
为什么我的背景图像在伪元素 ::before 内没有显示?我还测试了用背景颜色替换背景图像,但它仍然不起作用。这是 SASS 格式,以防有人对嵌套的 ::before 感到好奇。
.logoframe{
float: left;
height: 817px;
width: 20%;
position: relative;
left: -6%;
transform: skewX(-11deg);
border: 1px solid #e26f6f;
&::before{
content: "";
background-image: url('/images/theseven/seven_img_old.png');
background-repeat: no-repeat;
position: relative;
height: 817px;
width: 150px;
}
}Run Code Online (Sandbox Code Playgroud)
<div class="logoframe"></div>Run Code Online (Sandbox Code Playgroud)
小智 5
Sometimes you need to add background-size property too with display: block.
&::before{
content: "";
background-image: url('/images/theseven/seven_img_old.png');
background-repeat: no-repeat;
background-size:100%;
position: relative;
height: 817px;
width: 150px;
display:block;
}
Run Code Online (Sandbox Code Playgroud)