limonchik 96 Posted April 7, 2017 Report Share Posted April 7, 2017 <script type="text/javascript"> jQuery(function(){ jQuery('html, body').animate({ scrollTop: jQuery('#block').offset().top }, 2000); }); </script> Вот такой вот скрипт, при загрузке страницы скролит до нужного места (элемента), как сделать так чтоб он работал (скрипт) только при ширине экрана 800px и ниже... Спасибо! Quote Link to post Share on other sites
kaiwas 3 Posted April 7, 2017 Report Share Posted April 7, 2017 Не особо силён. Но сам гуглил бы на тему таких строк: if ($(window).width() <= 800){ ... }); } else{ ...} Quote Link to post Share on other sites
limonchik 96 Posted April 7, 2017 Author Report Share Posted April 7, 2017 Это я тоже видел, а полностью код, вместе со скриптом, как правильно написать... Quote Link to post Share on other sites
StayinLight 42 Posted April 7, 2017 Report Share Posted April 7, 2017 $(document).ready(function(){ $("body").addClass("js"); $('.slice-this').wTextSlicer({ height: '340', textExpand: 'Развернуть описание', textHide: 'Свернуть описание' }); $("#owl-top").owlCarousel({ navigation : true, navigationText: [ "<i class='fa fa-arrow-circle-left'></i>", "<i class='fa fa-arrow-circle-right'></i>" ], slideSpeed : 300, paginationSpeed : 400, singleItem:false, itemsCustom: [[0, 2], [470, 3], [590, 4], [760, 5], [950, 6], [1220, 8]], autoPlay:false, pagination: false, lazyLoad : true }); $("#owl-actors").owlCarousel({ navigation : true, navigationText: [ "<i class='fa fa-arrow-circle-left'></i>", "<i class='fa fa-arrow-circle-right'></i>" ], slideSpeed : 300, paginationSpeed : 400, singleItem:false, itemsCustom: [[0, 2], [470, 3], [600, 4], [760, 5], [940, 6], [1230, 8]], autoPlay:false, pagination: false }); $("#owl-rel").owlCarousel({ navigation : true, navigationText: [ "<i class='fa fa-arrow-circle-left'></i>", "<i class='fa fa-arrow-circle-right'></i>" ], slideSpeed : 300, paginationSpeed : 400, singleItem:false, itemsCustom: [[0, 2], [470, 3], [590, 4], [760, 5], [950, 5], [1220, 6]], autoPlay:false, pagination: false, lazyLoad : true }); Quote Link to post Share on other sites
wap_masterok 36 Posted April 7, 2017 Report Share Posted April 7, 2017 if (+$(window).width() <= 800){ $(function(){ $('html, body').animate({ scrollTop: $('#block').offset().top }, 2000); }); } Должно работать campusboy and limonchik 2 Quote Link to post Share on other sites
limonchik 96 Posted April 7, 2017 Author Report Share Posted April 7, 2017 Спасибо. Работает. С меню плюсик, выручили. В JS не силен, точнее вообще не силен. Тему можно закрыть. Цитата if (+$(window).width() <= 800){ $(function(){ $('html, body').animate({ scrollTop: $('#block').offset().top }, 2000); }); } Должно работать Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.