0
是否有可能在img元素上的僞選擇器之前和之後使用?認爲它是但沒有任何運氣,將CSS切換到一個div,它工作正常。 .page-overhang
類是img元素。:之前和之後:在img元素上的元素
// page overhang mixin
@mixin overhang {
&:before,
&:after {
position: absolute;
left: 0;
display: block;
width: 10px;
height: 18px;
background: url(../images/sprite.png) no-repeat;
content: "";
}
&:before {
top: -18px;
background-position: 0 -100px;
}
&:after {
bottom: -18px;
background-position: 0 -119px;
}
}
/* scss file */
.page-overhang {
position: relative;
display: block;
@include overhang();
}
':之前'和':之後'僞元素放置在元素的內部。如果該元素不能有子元素,':before'和':after'將不起作用。 – Shmiddty
謝謝,這很有道理,我猜從未嘗試過在圖像上使用它們。 – ferne97