【问题标题】:CSS width:fit-content not working on iphonesCSS 宽度:fit-content 在 iphone 上不起作用
【发布时间】:2020-05-20 00:14:17
【问题描述】:

我有一个元素的宽度设置为适合内容的 CSS 类。 CSS 在除 iPhone 之外的所有设备上都能正常工作。有谁知道解决方法吗??

.sidenav {
    width: fit-content;
    z-index: 100;
    padding-right: 15px;
}

【问题讨论】:

  • 请给我们更多关于问题的线索,你想要什么,以及实际得到什么
  • 将元素改为 inline-block 或 table

标签: html css iphone safari


【解决方案1】:

width: fit-content的支持不是很好。
https://caniuse.com/#feat=mdn-css_properties_width_fit-content

您可以改为使用 display: tablemargin: auto 来居中元素。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-12-11
    • 2021-06-22
    • 2012-01-28
    • 1970-01-01
    • 2012-10-25
    • 2018-03-03
    • 1970-01-01
    相关资源
    最近更新 更多