跨浏览器最小高度的最佳和有效方法是什么? [英] what is the best and valid way for cross browser min-height?

查看:40
本文介绍了跨浏览器最小高度的最佳和有效方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用于#main-content

我不想给出任何固定高度,因为内容可以很长,也可以很短,但是如果内容很短,则应该采用最小高度 500px .

I don't want to give any fix height because content can be long and short but if content is short then it should take minimum height 500px.

我需要与所有浏览器兼容.

i need compatibility in all browser.

在不使用!important的情况下,是否有任何w3c有效和跨浏览器的方式,因为我阅读了不应该使用!important

Is thery any w3c valid and cross browser way without using !important because i read !important should not be used

最后,请勿使用重要声明,除非您已经首先尝试其他一切,并保持考虑到任何弊端.如果您使用它,如果可能,在CSS中添加注释在任何样式旁边重写,以确保更好的代码可维护性.

In conclusion, don’t use the !important declaration unless you’ve tried everything else first, and keep in mind any drawbacks. If you do use it, it would probably make sense, if possible, to put a comment in your CSS next to any styles that are being overridden, to ensure better code maintainability.

我试图掩盖一切与使用有关的重要重要声明,请提供意见,如果您认为有我错过的任何事情,或者如果我已经遗漏任何东西,我会很高兴进行必要的更正.

I tried to cover everything significant in relation to use of the !important declaration, so please offer comments if you think there’s anything I’ve missed, or if I’ve misstated anything, and I’ll be happy to make any needed corrections.

http://www.impressivewebs.com/everything-you-ne-ne-to-ne-to-know-about-the-important-css-declaration/

推荐答案

min-height(请参见

min-height is supported in every major browser except IE6 (see QuirksMode).

在IE6中,即使元素具有固定的高度,它也会扩展以包含其内容.IE6中的高度实际上是最小高度.

In IE6, an element will expand to contain its content, even if it has a fixed height; height in IE6 is in effect min-height.

因此,跨浏览器的最小高度声明应为:

So a cross-browser min-height declaration would be:

#main-content {
    min-height: 500px;
}
* html #main-content { /* target IE6 */
    height: 500px;
}

这篇关于跨浏览器最小高度的最佳和有效方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆