<!DOCTYPE html> <html> <head> <style> body { font-family: "Lato", sans-serif; position: relative; height: 1700px; transition: all 0.3s; } .sidenav { height: 100%; width: 0; position: fixed; z-index: 1; top: 36px; left: 0; background-color: #111; overflow-x: hidden; transition: 0.5s; padding-top: 60px; } .sidenav a { padding: 8px 8px 8px 32px; text-decoration: none; font-size: 25px; color: #818181; display: block; transition: 0.3s; } .sidenav a:hover, .offcanvas a:focus{ color: #f1f1f1; } #main { position: fixed; top:0px; left: 300px; transition: opacity .5s ease-in; opacity: 1; padding: 4px 2px; width: 245px; height: 36px; background-color: #000000; margin-left: 1px; line-height: 36px; } #main0 { position: fixed; top:0px; left: 0px; transition: opacity .5s ease-in; opacity: 0; padding: 4px 2px; width: 245px; height: 36px; background-color: #000000; margin-left: 1px; line-height: 36px; } @media screen and (max-height: 450px) { .sidenav {padding-top: 15px;} .sidenav a {font-size: 18px;} } .openclosebtn{ font-size:30px;cursor:pointer; color: #FFFFFF; } h1{ margin: 0 auto; text-align: left; } </style> </head> <body> <div id="mySidenav" class="sidenav"> <a href="#">About</a> <a href="#">Services</a> <a href="#">Clients</a> <a href="#">Contact</a> </div> <div id="main0"> <span class="openclosebtn">☰ Меню сайта</span> </div> <div id="main"> <span class="openclosebtn">☰ Меню сайта</span> </div> <h1>test</h1> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> <script> $(function() { var a = 0, b; $(".openclosebtn").on("click", function(b) { b.stopPropagation(); b = a; a ^= 1; $(".sidenav").stop().animate({ width: 250 * a }, 500); $("#main").stop().animate({ opacity: 1 * b }, 500); $("#main0").stop().animate({ opacity: 1 * a }, 500); $("body").stop().animate({ "margin-left": 250 * a + "px" }, 500) }); }); </script> </body> </html> |
Dilettante_Pro,
да, можно сказать почти что искалось. Маленько подогнать под свои нужды и будет, что надо. Своими силами тоже постараюсь что-нибудь сделать, результат выложу, просто глянуть, что выйдет. Спасибки большие и рони и тебе за подмогу! |
squrell,
добавь в <script> $(function(){ $('.igrouplist a').mouseenter(function(){ top.location = this.href; }); }); |
j0hnik,
весь js во внешнем файле. Было так: window.addEventListener('DOMContentLoaded', function() { var body = document.querySelector('body'); document.addEventListener("click", function(event) { var target = event.target; if (target.closest(".sidenav") && !target.closest(".closebtn")) return; else if (target.closest("#main")) { event.preventDefault(); body.classList.toggle("open") } else body.classList.remove("open"); }); }); добавил, стало так: window.addEventListener('DOMContentLoaded', function() { var body = document.querySelector('body'); document.addEventListener("click", function(event) { var target = event.target; if (target.closest(".sidenav") && !target.closest(".closebtn")) return; else if (target.closest("#main")) { event.preventDefault(); body.classList.toggle("open") } else body.classList.remove("open"); }); }); $(function(){ $('.igrouplist a').mouseenter(function(){ top.location = this.href; }); }); Добавленное не работает. Я криво добавил? |
window.addEventListener('DOMContentLoaded', function() { var body = document.querySelector('body'); document.addEventListener("click", function(event) { var target = event.target; if (target.closest(".sidenav") && !target.closest(".closebtn")) return; else if (target.closest("#main")) { event.preventDefault(); body.classList.toggle("open") } else body.classList.remove("open"); }); [].forEach.call(document.querySelectorAll('.igrouplist a'), function(el){ el.onmouseenter=function(){ top.location = this.href; }; }); }); вот так сделай |
j0hnik,
сделал, но у меня не работает. Изменений не увидел, как было всё, так и осталось.. |
Цитата:
Убери этот кусок в общем. |
j0hnik,
подмогни с моим вопросом, не разобраться мне самому. |
Цитата:
Рони вам уже столько вариантов накидал, из них есть примеры что проще не придумаешь. возьмите какой нравится и пользуйтесь. тот можете еще глянуть, но они более сложные будут. https://sitesforprofit.com/incredibl...-menu-patterns |
рони, приветствую! Создал тему на основе твоего кода, продолжаю с ним эксперименты , глянь пожалуйста по возможнсти. Лежит здесь — http://javascript.ru/forum/site/7043...-po-kliku.html затемнение фона по клику.
|
Часовой пояс GMT +3, время: 14:37. |