css - 伪元素
问题描述
为什么伪元素 :before 或 :after 在 Firefox 中仅在 <button> 中没有光标指针?在其他浏览器中不存在此问题。简而言之,除了 <button> 之外的任何具有类 'button' 的元素都可以在所有浏览器中正常工作,包括 firefox。
示例:https ://codepen.io/Mr_Orange/pen/djKGwY
.area {
display: flex;
}
.block {
position: relative;
display: block;
width: 400px;
height: 400px;
background-color: lightgray;
margin-right: 32px;
}
.button {
display: inline-block;
background-color: orange;
border: 0;
padding: 12px 24px;
text-decoration: none;
color: white;
cursor: pointer;
}
.button:before {
position: absolute;
display: block;
top: 40px;
right: 40px;
bottom: 0;
left: 0;
width: 100%;
height: 100%;
content: "";
background: red;
z-index: 20;
}
<div class="area">
<div class="block">
<button type="button" class="button">test</button>
</div>
<div class="block">
<a href="#!" class="button">test</a>
</div>
</div>
解决方案
推荐阅读
- c - 调用函数时出现分段错误
- netsuite - NetSuite 营销活动 - 自定义事件字段 - 在营销模板中显示值
- groovy - Groovy:2.5.4:java.lang.ClassCastException:java.lang.Long 不能转换为 java.lang.String
- angular - 按角度名称从一个类别中获取所有产品
- javascript - 分页在首次加载时无法使用检索到的 api
- angular - 使用具有内容投影的其他组件测试 Angular 组件
- webpack - webpack - 最大化热模块替换只会触及编辑文件的机会
- excel - 用作绘图参考时,索引函数不起作用
- google-chrome - 不支持直通,gl 在使用 chromium 驱动程序 91 运行 salenium 项目时被禁用 ..plz 帮助它
- google-apps-script - 按 ID 将指定值从 CSV 导入 Google 工作表