gpt4 book ai didi

html - 为什么在这段代码中 Height : auto and Height: 100% on same element

转载 作者:行者123 更新时间:2023-11-28 18:05:58 28 4
gpt4 key购买 nike

我正在阅读 Bootsrap3 文档。我发现这段页脚代码粘在屏幕底部。

html, body {
height: 100%;
}
#wrap {
min-height: 100%;
height: auto !important; /* line no 1 */
height: 100%; /* line no 2 */
margin: 0 auto -60px;
padding: 0 0 60px;
}
footer {
height: 60px;
background-color: #f5f5f5;
}

我不明白他们为什么要多次定义环绕高度。据我所知,auto 将根据其子元素和 ! important 会强制浏览器使用这种风格。那么在这种情况下 height: 100% 就会生效。

我正在使用这段代码来测试一些东西。我用 height: auto !important; 写了两个 fiddle ,另一个没有这个代码。这是我的 JsFiddle1JsFiddle2那些 fiddle 是不言自明的。我只是不明白为什么会这样

最佳答案

一些较旧的浏览器,如 IE6,忽略 !important 标志。因此在 IE6 上,第二个 height 将被遵守。这只是一种针对旧版浏览器的方式。

关于html - 为什么在这段代码中 Height : auto and Height: 100% on same element,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19600624/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com