How To Create Scrolling Menu
Submitted by alpha_luna on Monday, April 18, 2016 - 15:45.
In this tutorial, we are going to learn on How To Create Scrolling Menu. It will help the user to navigate the menu easily. And it will increase the menu usability.
This is a fixed position scrolling menu that we have right now. And, we added a jQuery effect to scrolling smoothly.
Menu HTML
This is our scrolling menu.
And, this is our style.
jQuery Scrolling Effect
This script is used for our menu to have a smooth effect when the user scrolling the page.
Share us your thoughts and comments below. Thank you so much for dropping by and reading this tutorial post. For more updates, don’t hesitate and feel free to visit this website more often and please share this with your friends or email me at [email protected]. Practice Coding. Thank you very much.
Also, this is our scrolling content.
- <div id="scroll-content">
- <div id="Deluxe-content">
- This elegantly appointed room has 2 beds, a double bed and a single bed. It also comes with a writing desk and a coffee table set. The dimension of this room is 30 sqm. / 323 sqft.
- </div>
- <div id="Super-content">
- The super deluxe rooms are also known as the Business Class guest room with 2 beds, a double bed and a single bed. Relax and unwind after a long day and enjoy the bathtub in the cozy room. The dimension of this room is 30 sqm. / 323 sqft.
- </div>
- <div id="Matrimonial-content">
- The spacious matrimonial room is similar to the deluxe room but with one king bed and a larger room area.
- </div>
- <div id="Junior-content">
- The junior suite is a one bedroom suite with a king bed and comes with spacious sitting room. It is furnished with a dining set for 4 guests, a coffee table with two armchairs and a writing desk. The one and only Junior Suite is located at the fourth floor. The dimension of this room is 48 sqm. / 517 sqft.
- </div>
- <div id="Executive-content">
- There are 4 executive suites, three of which are a 2 room suite, while the other is a 1 bedroom suite. Designed for informal meetings and entertaining guests, the suites have a separate sitting room with a comfortable sofa, armchair, desk and dining table. The dimension of this room is 64 sqm. / 689 sqft.
- </div>
- </div>
- <style type="text/css">
- #scrolling-menu {
- position: fixed;
- width: 150px;
- margin-top:10px;
- }
- #scrolling-menu div {
- padding:11px;
- background: antiquewhite;
- color: blue;
- cursor:pointer;
- border:blue 1px solid;
- }
- #scrolling-menu div:hover {
- padding:11px;
- margin-bottom:1px;
- background: #C7B3B3;
- color: red;
- cursor:pointer;
- border:red 1px solid;
- }
- #scroll-content {
- border-left:#CCC 4px solid;
- margin-left:150px;
- padding-left:60px;
- color:black;
- }
- #scroll-content div {
- margin-bottom: 60px;
- }
- h1 {
- color:blue;
- }
- h1:hover {
- color:red;
- cursor:pointer;
- }
- </style>
- <script src="js/code_js.js"></script>
- <script>
- $(document).ready(function (){
- $(window).scroll(function(e){
- if ($(window).scrollTop() > ($('#scroll-content').height() - $('#scrolling-menu').height())){
- var scroll = $('#scroll-content').height() - $('#scrolling-menu').height();
- $(window).scrollTop(scroll);
- return false;
- }
- });
- $('#scrolling-menu div').click(function() {
- var target = $(this).attr('id');
- $('html, body').animate({scrollTop: $('#'+target+'-content').offset().top}, 1000);
- });
- });
- </script>
Add new comment
- 21 views