Dieses Forum nutzt Cookies
Dieses Forum verwendet Cookies, um deine Login-Informationen zu speichern, wenn du registriert bist, und deinen letzten Besuch, wenn du es nicht bist. Cookies sind kleine Textdokumente, die auf deinem Computer gespeichert sind; Die von diesem Forum gesetzten Cookies düfen nur auf dieser Website verwendet werden und stellen kein Sicherheitsrisiko dar. Cookies auf diesem Forum speichern auch die spezifischen Themen, die du gelesen hast und wann du zum letzten Mal gelesen hast. Bitte bestätige, ob du diese Cookies akzeptierst oder ablehnst.

Ein Cookie wird in deinem Browser unabhängig von der Wahl gespeichert, um zu verhindern, dass dir diese Frage erneut gestellt wird. Du kannst deine Cookie-Einstellungen jederzeit über den Link in der Fußzeile ändern.

Themabewertung:
  • 0 Bewertung(en) - 0 im Durchschnitt
  • 1
  • 2
  • 3
  • 4
  • 5
Bootstrap Fixed Menu mit Slide-Effekt
#1
Demo

HTML5
  1. <!DOCTYPE html>
  2. <html lang="de">
  3.  
  4.     <meta charset="utf-8">
  5.     <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  6.     <meta name="description" content="Bootstrap Fixed Menu mit Slide-Effekt">
  7.     <meta name="author" content="Bootstrap-Forum">
  8.     <title>Bootstrap Fixed Menu mit Slide-Effekt</title>
  9.  
  10.     <!-- Bootstrap core CSS -->
  11.     <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
  12.  
  13.     <!-- Place your stylesheet here-->
  14.     <link href="/css/stylesheet.css" rel="stylesheet" type="text/css">
  15.     <style>
  16.         .header_menu.fixed nav {
  17.             position: fixed;
  18.             top: -70px;
  19.             left: 0;
  20.             right: 0;
  21.             transform: translateY(70px);
  22.             transition: transform 500ms ease, background 500ms ease;
  23.             -webkit-transition: transform 500ms ease, background 500ms ease;
  24.             box-shadow: 0px 3px 16px 0px rgba(0, 0, 0, 0.3);
  25.             background-color: #6f5499 !important;
  26.         }
  27.  
  28.         .header_menu.fixed .nav-link {
  29.             line-height: 20px;
  30.         }
  31.  
  32.         .header_menu.fixed nav img.logo {
  33.             height: 35px;
  34.         }
  35.  
  36.     </style>
  37. </head>
  38.  
  39.     <header class="header_menu">
  40.         <nav class="navbar navbar-expand-md navbar-dark bg-dark main_menu">
  41.             <div class="container">
  42.                 <a class="navbar-brand" href="https://bootstrap-forum.de/"><img class="logo" src="img/logo.png" /></a>
  43.                 <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
  44.                     <span class="navbar-toggler-icon"></span>
  45.                 </button>
  46.  
  47.                 <div class="collapse navbar-collapse" id="navbarsExampleDefault">
  48.                     <ul class="navbar-nav ml-auto">
  49.                         <li class="nav-item active">
  50.                             <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
  51.                         </li>
  52.                         <li class="nav-item">
  53.                             <a class="nav-link" href="#">Link</a>
  54.                         </li>
  55.                         <li class="nav-item">
  56.                             <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
  57.                         </li>
  58.                         <li class="nav-item dropdown">
  59.                             <a class="nav-link dropdown-toggle" href="#" id="dropdown01" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropdown</a>
  60.                             <div class="dropdown-menu" aria-labelledby="dropdown01">
  61.                                 <a class="dropdown-item" href="#">Action</a>
  62.                                 <a class="dropdown-item" href="#">Another action</a>
  63.                                 <a class="dropdown-item" href="#">Something else here</a>
  64.                             </div>
  65.                         </li>
  66.                     </ul>
  67.  
  68.                 </div>
  69.  
  70.             </div>
  71.         </nav>
  72.     </header>
  73.     <main role="main" class="container">
  74.  
  75.         <div class="text-center mt-5 pt-5">
  76.             <h1>Bootstrap Fixed Menu mit Slide-Effekt</h1>
  77.             <p class="lead">Use this document as a way to quickly start any new project.<br> All you get is this text and a mostly barebones HTML document.</p>
  78.         </div>
  79.         <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus.</p>
  80.  
  81.         <p>Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante.</p>
  82.  
  83.         <p>Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc, quis gravida magna mi a libero. Fusce vulputate eleifend sapien. Vestibulum purus quam, scelerisque ut, mollis sed, nonummy id, metus. Nullam accumsan lorem in dui. Cras ultricies mi eu turpis hendrerit fringilla. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In ac dui quis mi consectetuer lacinia. Nam pretium turpis et arcu.</p>
  84.  
  85.         <p>Duis arcu tortor, suscipit eget, imperdiet nec, imperdiet iaculis, ipsum. Sed aliquam ultrices mauris. Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Praesent adipiscing. Phasellus ullamcorper ipsum rutrum nunc. Nunc nonummy metus. Vestibulum volutpat pretium libero. Cras id dui. Aenean ut eros et nisl sagittis vestibulum. Nullam nulla eros, ultricies sit amet, nonummy id, imperdiet feugiat, pede. Sed lectus. Donec mollis hendrerit risus. Phasellus nec sem in justo pellentesque facilisis. Etiam imperdiet imperdiet orci. Nunc nec neque.</p>
  86.  
  87.         <p>Phasellus leo dolor, tempus non, auctor et, hendrerit quis, nisi. Curabitur ligula sapien, tincidunt non, euismod vitae, posuere imperdiet, leo. Maecenas malesuada. Praesent congue erat at massa. Sed cursus turpis vitae tortor. Donec posuere vulputate arcu. Phasellus accumsan cursus velit. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed aliquam, nisi quis porttitor congue, elit erat euismod orci, ac placerat dolor lectus quis orci. Phasellus consectetuer vestibulum elit. Aenean tellus metus, bibendum sed, posuere ac, mattis non, nunc. Vestibulum fringilla pede sit amet augue. In turpis. Pellentesque posuere. Praesent turpis. Aenean posuere, tortor sed cursus feugiat, nunc augue blandit nunc, eu sollicitudin urna dolor sagittis lacus. Donec elit libero, sodales nec, volutpat a, suscipit non, turpis. Nullam sagittis. Suspendisse pulvinar, augue ac venenatis condimentum, sem libero volutpat nibh, nec pellentesque velit pede quis nunc. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Fusce id purus. Ut varius tincidunt libero. Phasellus dolor. Maecenas vestibulum mollis</p>
  88.         <p>Duis arcu tortor, suscipit eget, imperdiet nec, imperdiet iaculis, ipsum. Sed aliquam ultrices mauris. Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Praesent adipiscing. Phasellus ullamcorper ipsum rutrum nunc. Nunc nonummy metus. Vestibulum volutpat pretium libero. Cras id dui. Aenean ut eros et nisl sagittis vestibulum. Nullam nulla eros, ultricies sit amet, nonummy id, imperdiet feugiat, pede. Sed lectus. Donec mollis hendrerit risus. Phasellus nec sem in justo pellentesque facilisis. Etiam imperdiet imperdiet orci. Nunc nec neque.</p>
  89.  
  90.         <p>Phasellus leo dolor, tempus non, auctor et, hendrerit quis, nisi. Curabitur ligula sapien, tincidunt non, euismod vitae, posuere imperdiet, leo. Maecenas malesuada. Praesent congue erat at massa. Sed cursus turpis vitae tortor. Donec posuere vulputate arcu. Phasellus accumsan cursus velit. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed aliquam, nisi quis porttitor congue, elit erat euismod orci, ac placerat dolor lectus quis orci. Phasellus consectetuer vestibulum elit. Aenean tellus metus, bibendum sed, posuere ac, mattis non, nunc. Vestibulum fringilla pede sit amet augue. In turpis. Pellentesque posuere. Praesent turpis. Aenean posuere, tortor sed cursus feugiat, nunc augue blandit nunc, eu sollicitudin urna dolor sagittis lacus. Donec elit libero, sodales nec, volutpat a, suscipit non, turpis. Nullam sagittis. Suspendisse pulvinar, augue ac venenatis condimentum, sem libero volutpat nibh, nec pellentesque velit pede quis nunc. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Fusce id purus. Ut varius tincidunt libero. Phasellus dolor. Maecenas vestibulum mollis</p>
  91.     </main><!-- /.container -->
  92.  
  93.  
  94.     <!-- Bootstrap core JavaScript
  95.     ================================================== -->
  96.     <!-- Placed at the end of the document so the pages load faster -->
  97.     <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
  98.     <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
  99.     <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
  100.  
  101.     <script>
  102.         $(document).ready(function() {
  103.             (function($) {
  104.                 "use strict"
  105.                 var nav_offset_top = $('.header_menu').height() + 150;
  106.  
  107.                 /**  Navbar **/
  108.                 function navbarFixed() {
  109.                     if ($('.header_menu').length) {
  110.                         $(window).scroll(function() {
  111.                             var scroll = $(window).scrollTop();
  112.                             if (scroll >= nav_offset_top) {
  113.                                 $(".header_menu").addClass("fixed");
  114.                                 $('#searchInput').fadeOut();
  115.                             } else {
  116.                                 $(".header_menu").removeClass("fixed");
  117.                             }
  118.                         });
  119.                     };
  120.                 };
  121.                 navbarFixed();
  122.             })(jQuery)
  123.         });
  124.     </script>
  125. </body>
  126. </html>


Zitieren


Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 1 Gast/Gäste
[-]
Willkommen im ersten deutschen Bootstrap-Forum
You have to register before you can post on our site.

Benutzername/E-Mail:


Passwort:





[-]
Letzte Beiträge
eigene CSS für Firefox Browser
Last Post: Tapo
14.06.2019 13:47
» Replies: 2
» Views: 25
Frames?
Last Post: Daniel26
14.06.2019 08:31
» Replies: 4
» Views: 178
Bootstrap 4 Tutorials
Last Post: The-Error
07.06.2019 01:00
» Replies: 1
» Views: 4258

[-]
Private Messages
Please login or register to use this functionality.

[-]
Statistics
» Members: 245
» Latest member: Vikingscum
» Forum threads: 217
» Forum posts: 891

Full Statistics

[-]
Tutorials
Get Started
Text/Typography
Gridsystem
Dropdowns
Navigation Bar
Modal
Farben
Jumpotron
Popover
Formulare
Carousel (Slider)
Die Höhe von Elementen mit Klassen h-*
Flip Cards
Bild Overlay-Hover-Effekt
Google Fonts einbinden
Flexbox Bootstrap 4
Responsive Breakpoints

>