【发布时间】:2015-12-31 16:19:39
【问题描述】:
大家新年快乐!我需要一位更有经验的 html/css 架构师的帮助。我无法创建仅 CSS 和 Html(无 Javascript)自定义布局。其中包括:
1.顶部粘性标题,完全拉伸到页面宽度的 100%
2. 位于页眉下方的左侧菜单,高度完全拉伸到页面底部,如果您调整 页面宽度(媒体最小宽度为 845px)
3.一个粘滞页脚,位于左侧菜单旁边,但拉伸了页面的全部剩余宽度。
这是我目前的布局:http://jsfiddle.net/fksxb09y/
我的 HTML:
<div class="wrap">
<div class="header">STICKY HEADER</div>
<!-- Sidebar -->
<div id="sidebar-wrapper">
<ul class="sidebar-nav">
<li class="sidebar-brand">
<a href="#">
Start Bootstrap
</a>
</li>
<li>
<a href="#">Dashboard</a>
</li>
<li>
<a href="#">Shortcuts</a>
</li>
<li>
<a href="#">Overview</a>
</li>
<li>
<a href="#">Events</a>
</li>
<li>
<a href="#">About</a>
</li>
<li>
<a href="#">Services</a>
</li>
<li>
<a href="#">Contact</a>
</li>
</ul>
</div>
<!-- /#sidebar-wrapper -->
<div class="content">CONTENT
<br />CONTENT
<br />CONTENT
<br />CONTENT
<br />CONTENT
<br />CONTENT
<br />CONTENT
<br />CONTENT
<br />CONTENT
<br />CONTENT
<br />CONTENT
<br />CONTENT
<br />CONTENT
<br />
<br />CONTENT
<br />CONTENT
<br />CONTENT
<br />CONTENT
<br />CONTENT
<br />CONTENT
<br />CONTENT
<br />CONTENT
<br />CONTENT
<br />CONTENT
<br />CONTENT
<br />CONTENT
</div>
<div class="push"></div>
</div>
<div class="footer">STICKY FOOTER</div>
我的 CSS:
> html, body, .wrap { height: 100%; } .wrap { box-sizing:border-box; }
>
> form {height:100%} .wrap { min-height: 100%; height: auto
> !important; height: 100%; margin-bottom: -60px; /* for sticky
> footer to not go below page */ /* for sticky header to not overlap
> content */ } .push, .footer { height: 60px; } .footer {
> background-color: green; height: 60px; width: 100%; position:
> fixed; bottom: 0; } .content { padding-top: 60px; height:100%
> !important; background-color: yellow; } .header {
> background-color: blue; height: 60px; width: 100%; position:
> fixed; top: 0; }
>
>
> #sidebar-wrapper {
> z-index: 1000;
> position: fixed;
> left: 250px;
> width: 0;
> height: 100%;
> margin-left: -250px;
> overflow-y: auto;
> background: #000;
> -webkit-transition: all 0.5s ease;
> -moz-transition: all 0.5s ease;
> -o-transition: all 0.5s ease;
> transition: all 0.5s ease; }
>
> #wrapper.toggled #sidebar-wrapper {
> width: 250px; }
>
> #page-content-wrapper {
> width: 100%;
> position: absolute;
> padding: 15px; }
>
> #wrapper.toggled #page-content-wrapper {
> position: absolute;
> margin-right: -250px; }
>
> /* Sidebar Styles */
>
> .sidebar-nav {
> position: absolute;
> top: 0;
> width: 250px;
> margin: 0;
> padding: 0;
> list-style: none; }
>
> .sidebar-nav li {
> text-indent: 20px;
> line-height: 40px; }
>
> .sidebar-nav li a {
> display: block;
> text-decoration: none;
> color: #999999; }
>
> .sidebar-nav li a:hover {
> text-decoration: none;
> color: #fff;
> background: rgba(255,255,255,0.2); }
>
> .sidebar-nav li a:active, .sidebar-nav li a:focus {
> text-decoration: none; }
>
> .sidebar-nav > .sidebar-brand {
> height: 65px;
> font-size: 18px;
> line-height: 60px; }
>
> .sidebar-nav > .sidebar-brand a {
> color: #999999; }
>
> .sidebar-nav > .sidebar-brand a:hover {
> color: #fff;
> background: none; }
>
> @media(min-width:768px) {
> #wrapper {
> padding-left: 250px;
> }
>
> #wrapper.toggled {
> padding-left: 0;
> }
>
> #sidebar-wrapper {
> width: 250px;
> }
>
> #wrapper.toggled #sidebar-wrapper {
> width: 0;
> }
>
> #page-content-wrapper {
> padding: 20px;
> position: relative;
> }
>
> #wrapper.toggled #page-content-wrapper {
> position: relative;
> margin-right: 0;
> } }
如您所见,当我拉伸内容部分时,我在填充内容部分的整个高度时遇到了问题,而底部没有空白区域。
左栏布局覆盖页眉和页脚,而不是将页眉放在顶部,将页脚放在左栏的一侧。
我现在陷入了无望的困境,需要帮助来弄清楚这个布局。任何正确方向的帮助或提示将不胜感激。谢谢!
更新 1:感谢@DaMaGeX http://jsfiddle.net/fksxb09y/9/ 几乎解决了问题
现在我只需要弄清楚:
1. 为什么身体在 调整大小时底部。
2. 调整浏览器高度时 窗口粘性页脚与页眉重叠,最小高度 内容部分消失。调整大小时应该有足够大的空间容纳内容。
更新 2: 现在还有一个问题,我没有注意到左侧菜单上的底部箭头在调整大小时消失了,底部的内容也消失了。 http://jsfiddle.net/fksxb09y/9/
【问题讨论】:
-
感谢新年快乐!!!并且很好地描述了您的问题
-
谢谢@MarioKurzweil 也祝你新年快乐!
标签: html twitter-bootstrap css