0

Bootstrap DEFAULT-navbar jump to a few pixels under #point of my sections, anyway AFFIX-navbar works great.

You can check it here: http://kresyproduction.cz/

The problem is when i click on any link in default navbar it doesnt scroll in right way. Just like u can see on my page. Few pixels under the section and it hides some content. But when you scroll a little bit and the default navbar change to affix links work perfect.

<!DOCTYPE html>
<html lang="cs">
<head>
<meta charset="UTF-8">
    <title>Kresy Production</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="img/favicon.png">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" href="css/style.css">
    <link rel="stylesheet" href="css/font-awesome.min.css">
    <script src="js/jquery-1.12.4.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.0.4/popper.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js">
</script>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js">
</script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js">
</script>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
$(function() {
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') 
&& location.hostname == this.hostname) {
  var target = $(this.hash);
  target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
  if (target.length) {
    $('html,body').animate({
      scrollTop: target.offset().top
    }, 1000);
    return false;
  }
}
});
});
</script>

</head>
<body>
<nav class="navbar navbar navbar-default navbar-static-top" data-spy="affix" data-offset-top="50">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#domu"><img src="img/kp_white.png" alt="logo" title="Kresy Production" style="width auto;height: 30px;"></a>
            </div>

<!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav navbar-right">
                <li><a href="#domu">Domů</a></li>
                <li><a href="#sluzby">Služby</a></li>
                <li><a href="#showreel">Showreel</a></li>
                <li><a href="#onas">O nás</a></li>
                <li><a href="#kontakt">Kontakt</a></li>
            </ul>
            </div><!-- /.navbar-collapse -->
        </div><!-- /.container-fluid -->
    </nav>
</div>
.
.
</body>

enter image description here

enter image description here

  • I can detect no weird behaviour, it all works as one would expect. What browser are you using? (I tried Chrome and Firefox) – KIKO Software Feb 08 '18 at 09:26
  • 1
    I cannot see any unexpected behaviour on this website, http://kresyproduction.cz/. Can you share the screencast, by recording the video of the problem you are facing? – Yashu Mittal Feb 08 '18 at 09:27
  • Can you explain in more detail? – shakyl mansuri Feb 08 '18 at 09:34
  • I cant replicate an issue on the site. Could you provide more detail? – Aonghas M Feb 08 '18 at 09:35
  • You need this - body { padding-top: 70px; }. This would help - https://stackoverflow.com/questions/11124777/twitter-bootstrap-navbar-fixed-top-overlapping-site – T.Shah Feb 08 '18 at 11:20
  • Thank you for your help! I tried almost everything from thread provided by @T.Shah, but nothing work. Its strange that you cannot see any weird behaviour. I tried it on chrome, firefox and edge, everywhere the same issue. I hope this preview can help for understanding my question: https://youtu.be/lTMr73Klaj4 – Don Vqlidu Feb 08 '18 at 14:14
  • Post your html code then maybe we can help better – T.Shah Feb 08 '18 at 15:14
  • @T.Shah u can see it above, ps. i know it could be a little bit mess, but i am just a self-taught rookie – Don Vqlidu Feb 08 '18 at 16:01

1 Answers1

0

Your navbar has data-offset-top value. That is causing the issue. Change this

    <nav class="navbar navbar-default nav-fixed-top" data-spy="affix" data-offset-top="50">

to this -

    <nav class="navbar navbar-default nav-fixed-top" data-spy="affix" >

Hope this helps...

EDIT: 1 without removing data-offset-top value, edit it to this

    <nav class="navbar navbar-default navbar-fixed-top" data-spy="affix" data-offset-top="xx">  -- xx could be the data offset that works for you.
T.Shah
  • 2,768
  • 1
  • 14
  • 13