Remove body padding for fixed navbar

时间:2017-07-17 15:29:32

标签: html css twitter-bootstrap

I am using Bootstrap 2. Excited to upgrade to 4 eventually.

For now I have a site with a fixed top navbar. Looks great.

Now, I am working on some new pages pages. I will need the top navbar to NOT be fixed for these pages.

I have

body {
  padding-top: 117px;
}

in my css as the navbar on top is integral to the site... but

How can I "negate" this body padding for 2 pages where the navbar won't be fixed?

I tried adding a css class

.negate-nav-padding {
  margin-top: -117px;
}

but that did not work.

Thanks

2 个答案:

答案 0 :(得分:2)

为什么不在这两个页面上给一个覆盖类。像这样:

LinearLayout

答案 1 :(得分:1)

一个想法可能是向正文添加id并添加这些css规则:

body {
    padding-top: 117px;
}

body#special-page {
    padding-top: 0;
}

编辑:或类,例如:body.no-padding { padding-top: 0; }