它是确定没有使用它?我如何对旧版浏览器进行防弹测试?有一个跨浏览器的解决方案,以高度:理论值(100%-70px)
height: -moz-calc(100% - 70px);
height: -webkit-calc(100% - 70px);
height: calc(100% - 70px);
这是我正在努力完成的。
- 全宽度/固定高度头
- 绵延全宽和全高的滑块 - 减去报头的高度。
- 是在滑块垂直和水平居中的大字标题块
- A控制块,始终是从滑块
这里的底部固定高度是什么,我已经能够实现图像至今。这几乎是完美的,除了上面的粗体字部分。滑块(黑色区域)当前伸展100%的高度和标头,这是不正常为图像后面流动。
如果我添加填充物或保证金,它扩展了滑块高度超过100%,我得到一个滚动条。使用上面的高度计算似乎解决它,但是从我的理解,calc()
isn't compatible with IE 7, IE 8, iOS 5 or lower, or Android.
是否有此问题的一个更好的解决? jQuery是好的,但如果存在的话我宁愿一个CSS的解决方案。
这里是我的HTML:
<div class="header">
<h1>Header - Full Width + 70px Height</h1>
</div>
<div class="slider">
<div class="headline">
<div class="headline-container"><!-- for table-cell vertical centering -->
<h1>Headline Block</h1>
<p>Centered Horizontally & Vertically in the Slider Block</p>
</div>
</div>
<div class="controls">
<h2>Controls - Centered Horizontally & 40px from bottom of container</h2>
</div>
</div>
这里是我的CSS:
html, body {
width: 100%;
height: 100%;
margin: 0; padding: 0;
}
h1, h2, p {
margin: 0;
padding: 0;
}
.header {
position: absolute;
width: 100%;
height: 70px;
background-color: #888;
z-index: 9999;
}
.header h1 {
color: #fff;
text-align: center;
}
.slider-desc {
color: #fff;
text-align: center;
margin: 15px 0 0;
}
.slider {
width: 100%;
height: 100%;
background-color: #000;
}
.headline {
display: table;
width: 100%;
height: 100%;
}
.headline-container {
display: table-cell;
vertical-align: middle;
text-align: center;
}
.headline-container h1, .headline-container p {
background-color: #fff;
}
.controls {
position: absolute;
width: 100%;
bottom: 40px;
text-align: center;
background-color: yellow;
}
最后,I made a fiddle如果你想玩弄它。谢谢您的帮助!
你是什么意思?我没有回答 - 我在问一个问题。我正在寻找答案。 – timshutes
如果你想要一个可以在IE7中工作的纯粹的CSS解决方案,那么你几乎不会碰运气,因为你需要支持'display:table | table-cell'(IE8 +)。你最好的选择是让它看起来适合有能力的浏览器,并且它可以用于古董。 – cimmanon
只要不过重,我可以用jQuery解决方案。对我来说更重要的是Android/iOS的兼容性。 – timshutes