Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

danblukk

Members
  • Joined

  • Last visited

Everything posted by danblukk

  1. Using available code, Ive have a sticky menu that sticks to the top of the page when the user scrolls using JQuery. But for the world of me I just cant get it to centre, it stays left. I've tried padding but that messes up the JQuery bit. I just want it centred under my title and to stay centred when scrolled. I've tried text-align:center with margin:0 auto, I've tried creating a new div id with rules margin:auto; text-align:center; and setting the width but it just wont centre. I've got everything the way I want it except this one thing. can anybody help? Heres the code i have JQuery <script> $(function() { // grab the initial top offset of the navigation var sticky_navigation_offset_top = $('#sticky_navigation').offset().top; // our function that decides weather the navigation bar should have "fixed" css position or not. var sticky_navigation = function(){ var scroll_top = $(window).scrollTop(); // our current vertical position from the top // if we've scrolled more than the navigation, change its position to fixed to stick to top, // otherwise change it back to relative if (scroll_top > sticky_navigation_offset_top) { $('#sticky_navigation').css({ 'position': 'fixed', 'top':0 }); } else { $('#sticky_navigation').css({ 'position': 'relative' }); } }; // run our function on load sticky_navigation(); // and run it again every time you scroll $(window).scroll(function() { sticky_navigation(); }); }); </script> HTML <div id="demo_top_wrapper"> <!-- a header with a logo just to have some content before the menu --> <!-- this will be our navigation menu --> <div id="sticky_navigation_wrapper"> <div id="sticky_navigation"> <div class="demo_container"> <div id="demo_container"> <ul> <li><center><a href="#">About Me</a></center></li> <li><center><a href="#">My Work</a></center></li> <li><center><a href="#">Experience</a></center></li> <li><center><a href="#">Contact Me</a></center></li> </ul> </div> </div> </div> </div> </div><!-- #demo_top_wrapper --> CSS #demo_container { margin:auto; text-align:center; } .demo_container { width:980px; } #demo_top_wrapper { margin:0 0 20px 0; } #demo_top { height:100px; padding:20px 0 0 0; } #my_logo { font:70px Georgia, serif; } /* our menu styles */ #sticky_navigation_wrapper { margin:0 auto; width:100%; height:50px; } #sticky_navigation { text-align:center; margin:0 auto; width:auto; height:50px; background:url(trans-black-60.png); -moz-box-shadow: 0 0 5px #999; -webkit-box-shadow: 0 0 5px #999; box-shadow: 0 0 5px #999;float:centre } #sticky_navigation ul { list-style:none; margin:0; padding:5px; } #sticky_navigation ul li { margin:0; padding:0; display:inline; } #sticky_navigation ul li a { display:block; float:left; margin:0 0 0 5px; padding:0 20px; height:40px; line-height:40px; font-size:14px; font-family:Arial, serif; font-weight:bold; color:#ddd; background:#333; -moz-border-radius:3px; -webkit-border-radius:3px; border-radius:3px; }

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.