javascript - Safari 上的 CSS 项目重叠
问题描述
我正在为我的应用程序创建一个音频播放器,它有一个暂停/播放按钮、下一个按钮和后退按钮。我只在返回/暂停按钮相互重叠的 Safari 上遇到问题。播放/暂停按钮取决于当前的播放状态。在 Chrome、firefox 和 IE 上没有重叠。我只是在 safari 上遇到问题,有人可以帮忙吗?Styles.pause/styles.play 与 styles.back_container 重叠
const [play, setPlay] = useState(false)
<div className = {styles.play_container}>
<div className={play ? styles.pause : styles.play} onClick={handlePlay}></div>
<div className = {styles.next_container} onClick={()=>handleNext()}>
<div className={styles.skip1}></div>
<div className={styles.skip2}></div>
</div>
<div className = {styles.back_container} onClick={()=>handleBack()}>
<div className={styles.back1}></div>
<div className={styles.back2}></div>
</div>
</div>
.play_container{
display: flex;
top: 40%;
position: absolute;
z-index: 2000;
height: 2%;
width: 68%;
/* left: 70px; */
justify-content: center;
}
.pause{
z-index: 2100;
height: 20px;
border-style: double;
border-width: 0px 0px 0px 19px;
border-color: #202020;
visibility: visible;
cursor: pointer;
}
.play{
z-index: 2100;
border-style: solid;
height: 20px;
border-width: 10px 0px 10px 15px;
border-color: transparent transparent transparent #202020;
box-sizing: border-box;
visibility: visible;
cursor: pointer;
}
.next_container{
display: flex;
position: absolute;
z-index: 2100;
width: 20px;
height: 20px;
cursor: pointer;
margin-left: 100px;
justify-content: center;
}
.back_container{
display: flex;
position: absolute;
z-index: 2100;
width: 20px;
height: 20px;
cursor: pointer;
margin-right: 100px;
justify-content: center;
}
.skip1{
z-index: 2100;
width: 20px;
height: 5px;
border-style: solid;
border-width: 7px 0px 7px 7px;
border-color: transparent transparent transparent #202020;
box-sizing: border-box;
visibility: visible;
margin-top: 3px;
}
.skip2{
z-index: 2100;
height: 14px;
border-left: 2.5px solid #202020;
visibility: visible;
margin-right: 10px;
margin-top: 3px;
}
.back1{
z-index: 2100;
height: 14px;
border-left: 2.5px solid #202020;
visibility: visible;
margin-left: 10px;
margin-top: 3px;
}
.back2{
z-index: 2100;
width: 20px;
height: 5px;
border-style: solid;
border-width: 7px 7px 7px 0px;
border-color: transparent #202020 transparent transparent;
box-sizing: border-box;
visibility: visible;
margin-top: 3px;
}
解决方案
这是一个奇怪的问题,但我发现如果我为 back_container 指定一个左值并使用我能够按预期定位的变换:
.back_container{
display: flex;
position: absolute;
z-index: 2100;
width: 20px;
height: 20px;
cursor: pointer;
margin-right: 100px;
justify-content: center;
left: 50%;
transform: translateX(-100px);
}
左值使后退按钮居中(在播放按钮的顶部),变换将其移回所需的 100 像素。我个人会制作一个容器,它是控件所需的宽度,并将它们与 flexbox 或网格对齐(也许 flex 之间有合理的空间),然后将播放容器居中,但上面的代码应该是一个快速修复。
推荐阅读
- amazon-web-services - 可以将弹性 IP 附加到 sagemaker 笔记本实例吗?
- javascript - Using Vue how do you call a function when a user clicks on a bootstrap-selectpicker option
- javascript - Javascript如何在输入3个字符后显示自动建议结果
- node.js - 如何根据对象查询mongodb以获取包含一个或多个相等属性的文档(搜索)
- javascript - How can I do Shallow copy of tree using recursion
- python - Verify the authentication of sales achievement with Benford's law
- css - Can a CSS selector search part of a word?
- python - Google Colab 中保存的文件位于何处?
- c# - 未找到与约束匹配的导出:问题让我的 wpf 应用程序与 MEF 一起工作
- python - Python: match numbers from another file and return parameter