我有一个奇怪的问题。我在网站上各处都使用这段代码,而且它在所有地方都有效。但是出现在此处时,它却无法工作。
基本上,我的做法是通过使用伪元素
基本上,我的做法是通过使用伪元素
:before
和 :after
来创建一个半透明的背景图像,以填充整个容器,使其具有背景颜色 (:before
) 和半透明图像 (:after
)。 :before
元素很好用,可以按预期填充 .dashboard-page
的高度和宽度。但是,:after
元素的宽度为100%,但高度为0,因此图像没有显示出来。非常感谢您的帮助。.dashboard-page {
width: 100%;
position: relative;
z-index: 1;
@include clearfix;
&:before,
&:after {
content: '';
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
@include transition($transition-main);
}
&:before {
z-index: -2;
background-color: $blue-light;
}
&:after {
opacity: 0.02;
z-index: -1;
background-image: url('../life/assets/img/pattern.png');
}
}
content: ''
更改为带有空格的content: ' '
。 - Novocaine