min-height: auto not working in Opera

2019-06-16 20:59发布

问题:

I have noticed that min-height is not working in Opera. I am trying something like this:

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

And my CSS code is:

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

And Opera just acts like min-height didn't exist.
If I apply any other style in .newstyle, like background or whatever, then it works well. But min-height: auto seems not to work...

Any idea?

回答1:

CSS2.1 defines the initial value of min-height to be 0, not auto. The value auto never existed in CSS2.1, so it is invalid in CSS2.1. Just use min-height: 0 instead:

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


回答2:

auto; is not a valid value for min-height property and hence Opera ignores...

You can specify min-height using px, cm etc, or % or inherit

Sitepoint Reference



标签: css opera