Twitter Bootstrap Responsive Navbar Broken on Small Screens

后端 未结 2 1869
北荒
北荒 2021-02-13 09:55

I\'ve been reading the docs and comparing my code to Bootstrap\'s examples, but I cannot figure out why the navbar on my site drops down about 100px when I make my browser windo

2条回答
  •  我在风中等你
    2021-02-13 10:42

    The visual anomaly appears because you defined the top padding for the body element after including the bootstrap-responsive.css file, which means that the "responsive" styles are unable to override your padding:

    
    
    
    
    

    You want the padding to be used when the page is displayed at full width (so that your main content doesn't get displayed underneath the top navbar), but you want the "responsive" styles to override that padding when you shrink the browser width (or display the page on a mobile device).

    So the fix is simple: define the top padding for the body element between your inclusion of bootstrap.css and bootstrap-responsive.css.

    The Bootstrap samples are a great template to use to get started. The fluid layout site does it like this:

    
    
    
    
    

提交回复
热议问题