html - 文本缩进 - 在 Safari 中不显示文本
问题描述
我是编码新手,我在文本缩进和 safari 方面遇到了一些问题。
在 chrome 和 firefox 上,一切正常。问题是我做了两个按钮,一个在另一个上面,文本彼此相邻,文本没有显示在 safari 上。
已经浪费了3个小时,我不知道该怎么办。
这是jsfiddle
.btn-group .button {
background:url(https://image.ibb.co/iSdLzS/red.jpg) no-repeat;
cursor: pointer;
width: 100px;
height: 100px;
object-fit: cover;
background-size: 100%;
display: block;
text-indent: 105px;
font-size: 25px;
font-kerning: normal;
font-family: Lato,sans-serif;
text-decoration: none;
color: #007896;
border: none;
opacity: 1;
transition: 0.3s;
}
.btn-group .button:not(:last-child) {
border-right: none; /* Prevent double borders */
}
.btn-group .button:hover {opacity: 0.8
}
.btn-group .button2 {
background:url(https://image.ibb.co/fskHeS/blue.png) no-repeat;
cursor: pointer;
width: 100px;
height: 100px;
object-fit: cover;
background-size: 100%;
display: block;
text-indent: 105px;
font-size: 25px;
font-kerning: normal;
font-family: Lato,sans-serif;
text-decoration: none;
color: #007896;
border: none;
opacity: 1;
transition: 0.3s;
}
.btn-group .button2:not(:last-child) {
border-right: none; /* Prevent double borders */
}
.btn-group .button2:hover { opacity: 0.8
}
<div class="btn-group">
<button class="button">Reeeed</button><br>
<button class="button2">Blue</button>
</div>
解决方案
在这里您会找到类似的问题,但我尝试了答案然后没有用
然后我已经完成了这个技巧position
并尝试了自己,希望它会有所帮助
您必须为文本创建一个p
标签并定位它们absolute
,但使用父按钮relative
然后将它们垂直居中。
.btn-group .button {
background:url(https://image.ibb.co/iSdLzS/red.jpg) no-repeat;
cursor: pointer;
position:relative;
width: 100px;
height: 100px;
object-fit: cover;
background-size: 100%;
display: block;
text-indent: 105px;
font-size: 25px;
font-kerning: normal;
font-family: Lato,sans-serif;
text-decoration: none;
color: #007896;
border: none;
opacity: 1;
transition: 0.3s;
}
.btn-group .button:not(:last-child) {
border-right: none; /* Prevent double borders */
}
.btn-group .button:hover {opacity: 0.8
}
.btn-group .button2 {
background:url(https://image.ibb.co/fskHeS/blue.png) no-repeat;
cursor: pointer;
width: 100px;
height: 100px;
object-fit: cover;
background-size: 100%;
display: block;
text-indent: 105px;
font-size: 25px;
font-kerning: normal;
font-family: Lato,sans-serif;
text-decoration: none;
color: #007896;
border: none;
opacity: 1;
position:relative;
transition: 0.3s;
}
.btn-group .button2:not(:last-child) {
border-right: none; /* Prevent double borders */
}
.btn-group .button2:hover { opacity: 0.8
}
button p {
position: absolute;
top: 0;
bottom:0;
}
<div class="btn-group">
<button class="button"><p>Reeeed</p></button><br>
<button class="button2"><p>Blue</p></button>
</div>
推荐阅读
- python - 无法在 html 中使用 python 变量 | 姜戈
- python - Medium.com 无效的 Json?
- ios - 如何防止iOS Webkit长按链接?
- c# - 在 IServiceCollection 上注册通用配置的方法
- mql4 - 我对我的代码中的 ordersend 和 orderclose 中的 mql4 有一些疑问
- android-recyclerview - 如何将 onClick 侦听器应用于 CardView 中的 imageView
- javascript - 专业人士在哪里?以下代码不适用于 iOS
- java - 如何单击警报中的按钮?
- branch.io - Branch.io:有没有办法指定分支横幅可以出现在单页应用程序中的哪个页面上?
- javascript - 从谷歌云存储下载文件导致nodejs内存泄漏