<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <link rel="stylesheet" href="styles.css" /> <!-- . --> </head> <body> <nav id="hide">”<!— . --> <ul> <li><a href="#link-1" class="selected"></a></li> <li><a href="#link-2"> I</a></li> <li><a href="#link-3"> II</a></li> <li><a href="#link-4"> III</a></li> <li><a href="#top" id="go-top">⇑ ⇑</a> </li> </ul> </nav> <div class=wrapper> <h1> .</h1> <section id=" link-1"> ...</section> </div> </body> </html>
#hide { width:100%; height:40px; padding: 20px 0; position: fixed; top: 0px; margin:0px; background-color:#287455; text-align:center; opacity:0.9; filter:alpha(opacity=90); -moz-opacity:0.9; } #hide li a { text-decoration: none; font-size: 20px; color: #000; font-weight: bold; display: inline-block; width: 120px; text-align: center; padding: .80px 16px; } nav li a:hover, nav li a.selected { color: #000; z-index:5; background: #40bfe8; }
<script src="jquery-1.6.4.min.js" type="text/javascript"></script> <script> $(document).ready(function(){ $("#hide").hide(); $(function () { $(window).scroll(function () { if ($(this).scrollTop() > 100) { $('#hide').fadeIn(); } else { $('#hide').fadeOut(); } }); $('#go-top').click(function () { $('body,html').animate({ scrollTop: 0 }, 800); return false; }); }); }); </script>
Source: https://habr.com/ru/post/178305/
All Articles