html - 溢出:隐藏不会在 iOS Safari 上创建新的块格式化上下文
问题描述
我正在尝试编写一个样式表来设置以下 html 的样式
body > * {
width: 49%; /* should be 50% */
display: inline-block;
text-align: center;
overflow: hidden;
margin: 0;
}
body {
margin: 0 auto;
line-height: 0px;
width: 80%;
}
<html><body>
<span><h1>some text here</h1></span>
<img src="img.png"></body></html>
但在 iOS Safari 上,h1 的下边距扩展超过基线,并且(在完整版本中,有多行),下推其余内容。如果我使用overflow: scroll
,这会为 Safari 修复它,但在其他浏览器上会破坏视图。我怎样才能检测到这是 Safari 并修复它或使用不同的方式来构建块格式化上下文?我宁愿不使用 Javascript,但我认为有机会我必须这样做。
解决方案
是否溢出:隐藏应用于 <body> 在 iPhone Safari 上工作?
body > * {
position:relative;
overflow:hidden;
}
推荐阅读
- sql-server - 如何有效地匹配 SQL Server 中的日期?
- mongodb - 用于嵌套信息的更好的 mongodb 数据模型
- reporting-services - SSRS 中的日期时间参数
- c# - 以编程方式调整 DataGrid 列 OnLoaded
- php - Symfony 棘轮 WSS
- python - add_subparsers 不能识别 sub_argument
- javascript - React - 事件发生时如何更改子组件的道具?
- android - FlatMapCompletable 不会继续 Rx 链,但是带有“andThen(Observable.just(true)”的可完成的平面图可以工作吗?
- java - Tomcat Maven - 无法启动组件问题
- c# - 如何检查 Parse(args) 是真还是假