简体   繁体   中英

Bootstrap sidebar and footer not working properly

I have to add a footer for many web pages developed using jQuery and bootstrap 3. I have written the following script based on this Bootstrap's example to do the job

// Default
$( document ).ready(function() {
        $('body').append('<footer class="footer">' + 
                               ' © 2015 ABC Company. All rights reserved. | Content for internal use only. | ' +
                               '<a href="mailto:#">Contact Us</a> ' +
                          ' </footer>');
});

related CSS

html {
  position: relative;
  min-height: 100%;
}
body {
  /* Margin bottom by footer height */
  margin-bottom: 40px;
}
.footer {
  position: absolute;
  bottom: 0;
  width: 100%;
  /* Set the fixed height of the footer here */
  height: 40px;
  background-color: #99FFFF;
  padding-top:5px;
}

This work well for all pages except pages with sidebars where the sidebar overlaps the footer like below

页脚和侧边栏的重叠

I have tried to fix it by adding margin-bottom: 40px; /* Margin bottom by footer height */ margin-bottom: 40px; /* Margin bottom by footer height */ to .sidebar in CSS. Now it looks like below

侧边栏底部的空白

页面底部的页脚

Bootply

How to fix this? I can't add and style individual footer for each page as there are many pages.

在页脚的CSS中添加z-index:600,将使页脚位于所有内容的顶部。

You need to tell your footer to be displayed in front of other elements on the page. Using the z-index CSS property should help with this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM