twitter-bootstrap – Twitter Bootstrap 3 – 最大高度,自定义布局

前端之家收集整理的这篇文章主要介绍了twitter-bootstrap – Twitter Bootstrap 3 – 最大高度,自定义布局前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我有这样的事情:

  1. +-------------------------------------------+
  2. | -- navigation -- |
  3. +------+------------------------------------+
  4. | | |
  5. | left | |
  6. | side | |
  7. | with | |
  8. | affix| -- content (white) -- |
  9. | menu | |
  10. |-black| |
  11. | | |
  12. | | |
  13. | +------------------------------------+
  14. | | -- footer (white) -- |
  15. +------+------------------------------------+

作为我在TB 3.0中的布局,以及一些代码

我想让我的左侧(黑色背景)和内容(白色背景)高度=我的浏览器窗口和页脚(白色背景)100%在我的内容下方可见(也在滚动上).

现在,我得到了最后一个元素的高度.如果我的内容很短,则会在浏览器的垂直中心结束.

这是它:http://codepen.io/anon/pen/FxImy

最佳答案
纯CSS解决方案(使用calc)

如果你可以使用CSS3,并且这个50px高度是静态的,你可以使用calc来实现你的布局.

这是一个DEMO

HTML

CSS

  1. *
  2. {
  3. padding: 0;
  4. margin: 0;
  5. }
  6. html,body
  7. {
  8. height: 100%;
  9. }
  10. header,footer
  11. {
  12. height: 50px;
  13. background-color: yellow;
  14. text-align: center;
  15. }
  16. #Container,#Content
  17. {
  18. height: calc(100% - 50px);
  19. overflow: auto;
  20. }
  21. #Left,#Right
  22. {
  23. height: 100%;
  24. }
  25. #Left
  26. {
  27. float: left;
  28. background-color: black;
  29. color: white;
  30. }
  31. #Right
  32. {
  33. overflow: auto;
  34. }

如果高度不是静态的,我会为你提供另一个解决方案,我演示了here它不是你的布局,但它可以用同样的方式完成.

猜你在找的CSS相关文章