İçereği Atla
Menü
Bu soru işaretlendi
3 Cevaplar
14655 Görünümler

How can I let the website navbar stay on top of the screen when scrolling down like https://willowit.com.au?

When I change <div class="navbar navbar-default navbar-static-top"> to <div class="navbar navbar-default navbar-fixed-top">, the menu stays on top. Only problem is that the website editing bar is not correctly displayed when the user is logged in and wants to edit the website.

Avatar
Vazgeç
En İyi Yanıt

The simplest solution is probably to make a switch.

I had tried the user navbar with fixed-top, with fixed-bottom and z-index manipulation. The problem is that there are too many draws more disorders by itself.

I now have it solved so that visitors can see a fixed navbar and backend-user a static navbar. In addition I had to edit only two places in the Main layout:

new opening body 

<body t-att-style="'' if editable else 'padding-top:51px;'">
and a bit further down the new navbar div

<div t-att-class="'navbar navbar-default navbar-static-top' if editable else 'navbar navbar-default navbar-fixed-top'"> 

not an optimal solution - but works so far 

Avatar
Vazgeç
En İyi Yanıt

To add on the accepted answer, it's better to use "if website.user_id != user_id else" instead of "if editable". Because when it's "if editable",  if your website has more than one language installed, you won't be able to translate them, because the navbar overlaps the editor navbar. 

My navbar tag: 

<div t-att-class="'navbar navbar-static-top' if website.user_id != user_id else 'navbar navbar-fixed-top'">
Avatar
Vazgeç
En İyi Yanıt

Add this to body tag:

 

body {

min-height: 2000px;

padding-top: 70px;

}

 

The problem is from bootstrap, not odoo. When you fix top, the container adapts, so you need to add the padding, so it restores to the previous size. 

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
4
May 25
2386
2
Oca 25
2111
4
Oca 25
4187
0
Kas 24
1517
1
Kas 24
2282