kanv1s Posted August 10, 2015 Share Posted August 10, 2015 Здравствуйте. На форуме установлена "стрелка вверх", наподобие VK. Когда прокручиваешь форум вниз, она появляется слева, по всей длине экрана.Все замечательно, удобно и всем нравится. Проблема вскрылась у пользователей планшетов и мобилок.Стрелка перекрывает активные участки, что мешает отвечать в темах (просто читать форум, не мешает).Стрелка работает на JS. Вопрос следующий.Можно ли в JS задать условие, что бы при определенной ширине экрана, стрелка просто не показывалась? Вот кодjQuery(document).ready(function() { jQuery('body').append('<div class="button-up" style="display: none;opacity: 0.7;width: 40px;height:100%;position: fixed;left: 0px;top: 0px;cursor: pointer;text-align: center;line-height: 30px;font-size:20px;color: #d3dbe4;font-weight: bold;">↑</div>'); jQuery (window).scroll (function () { if (jQuery (this).scrollTop () > 100) { jQuery ('.button-up').fadeIn(); } else { jQuery ('.button-up').fadeOut(); } }); jQuery('.button-up').click(function(){ jQuery('body,html').animate({ scrollTop: 0 }, 0); return false; }); jQuery('.button-up').hover(function() { jQuery(this).animate({ 'opacity':'1', }).css({'background-color':'#fff','color':'rgb(136, 136, 136)'}); }, function(){ jQuery(this).animate({ 'opacity':'0.7' }).css({'background':'none','color':'#d3dbe4'});; }); }); Пытался скрыть ее, используя CSS (@media screen), но не получается. А в JS разбираюсь плохо. Link to comment Share on other sites More sharing options...
siv1987 Posted August 11, 2015 Share Posted August 11, 2015 jQuery(document).ready(function() { if(jQuery(window).width() <= 650){ return; } 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now