如何使文本可选?我已经用z-index尝试过了
.blue {
background-color: blue;
}
.lighten {
opacity: 0.5;
}
.relative {
position: relative;
}
.absolute {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}Run Code Online (Sandbox Code Playgroud)
<div class="relative">
this text cannot be selected
<div class="absolute blue lighten">
</div>
</div>Run Code Online (Sandbox Code Playgroud)
禁用绝对定位元素上的指针事件,它将允许您选择它背后的文本
.blue {
background-color: blue;
}
.lighten {
opacity: 0.5;
}
.relative {
position: relative;
}
.absolute {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
}Run Code Online (Sandbox Code Playgroud)
<div class="relative">
this text can now be selected
<div class="absolute blue lighten">
</div>
</div>Run Code Online (Sandbox Code Playgroud)