html - Safari 截取图片包括 ( png, svg )
问题描述
图像在除 safari 之外的其他浏览器上正常显示,例如 chrome、firefox。野生动物园似乎切断了图像
以下是使用chrome和firefox时的正确行为
在 safari 中砍掉图像
我的 HTML 5 代码是
<div class="sound-control" style="position: absolute;left:0;top:0">
<button class="sound-control-item" id="mute-btn">
<img src="/assets/On_trans.svg" />
</button>
<button class="sound-control-item" id="unmute-btn">
<img src="/assets/Off_trans.svg" alt="">
</button>
</div>
我的 CSS3 代码是
.sound-control{
padding:10px;
z-index:1000000;
}
.sound-control-item{
width:40px;
height: 40px;
font-size:18px;
outline:none;
color:white;
z-index:9999999;
background-color:transparent;
border-radius:100%;
border-color:transparent;
border:none;
}
#mute-btn{
display: none;
}
我还尝试了以下 stackoverflow 答案,但没有运气。
解决方案
我的问题解决了。罪魁祸首是按钮的高度和宽度属性。我给了图像width:50px
(它是按钮的子元素),而按钮(在这种情况下是父元素)是width:40px
.
Chrome 和 Firefox 似乎可以自动处理这个宽度问题,但 safari 无法处理这个问题。
sound-control-item{
width:50px; # I changed this from 40px -> 50px
height:auto; # I changed this from 40px -> auto
font-size:18px;
outline:none;
color:white;
z-index:9999999;
background-color:transparent;
border-radius:100%;
border-color:transparent;
border:none;
}
推荐阅读
- flutter - 如何更改 Flutter PDF 库中文本小部件中的字体?
- sql-server - 如何在 SQL Server 中进行累计?
- google-apps-script - 例外:参数 () 与 FormApp.TimeItem.createResponse 的方法签名不匹配。(第 117 行,文件“代码”)
- xamarin.forms - 共享项目中的提取文件夹引发访问异常
- angular - Ngrx 单元测试效果
- android - 在哪里构建数据源以在颤动的屏幕中显示
- html - Safari:尝试保持纵横比时出现对象包含问题
- python - 循环遍历python烧瓶中的多个返回重定向
- r - R Plotly 对数直方图
- vue.js - 当我尝试运行测试用例时,它显示了 shallowMount 错误,如何修复 VUE.JS 中的 ShallowMount 错误?