【问题标题】:min-height: auto not working in Opera最小高度:自动在 Opera 中不起作用
【发布时间】:2023-03-11 15:54:01
【问题描述】:

我注意到min-height 在 Opera 中不起作用。我正在尝试这样的事情:

<div class="content"><div>
<div class="content newstyle"><div>

我的 CSS 代码是:

.content {
    min-height: 600px;
}
.newstyle {
    min-height: auto;
}

Opera 就像 min-height 不存在一样。
如果我在.newstyle 中应用任何其他样式,例如背景或其他样式,则效果很好。但是min-height: auto 好像不行……

有什么想法吗?

【问题讨论】:

    标签: css opera


    【解决方案1】:

    CSS2.1 defines the initial value of min-height to be 0, not auto.auto的值在CSS2.1中从未存在过,因此在CSS2.1中无效。只需改用min-height: 0

    .content {
        min-height: 600px;
    }
    .newstyle {
        min-height: 0;
    }
    

    【讨论】:

    • 它已从 Flexbox 模块中删除,TR 链接锚 #min-size-auto 不再有效。
    • @danorton:谢谢,我已经完全删除了 flexbox 引用。
    • 对于那些搜索,同样的事情会在 Safari 中发生。稍微烦人的事情是,如果你正在开发例如。 Chrome,您不会注意到,因为 Chrome 允许您仍然使用 auto。 :)
    【解决方案2】:

    auto; 对于min-height 属性不是有效的value,因此Opera 会忽略...

    您可以使用pxcm 等或%inherit 指定min-height

    Sitepoint Reference

    【讨论】:

    • 如果我只是不想建立最小高度但我想忽略其他样式的最小高度怎么办?
    • @BoltClock 不,我认为auto 无效
    • @Steve 没有得到你,顺便说一句,你不需要使用min-height: auto;,因为你的 div 高度默认是自动的,除非你给 div 一些高度
    • 最小高度:0 没关系。我太傻了:)谢谢!
    • @BoltClock min-height: 0 有什么用?因为浏览器默认的 div 高度设置为 auto
    猜你喜欢
    • 2017-10-06
    • 2013-06-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多