Answer the question
In order to leave comments, you need to log in
How to make an anchor menu in Bitrix?
When creating a regular menu, sections are created, but I don’t need them, I have a one-pager. Accordingly the question. How to make an anchor menu in Bitrix so that it can be edited from the admin panel? Who faced, can you explain?
Answer the question
In order to leave comments, you need to log in
just like a regular menu. Only for example instead of /catalog/ write #block1. Anchor #block1 will be added to the href of the created menu. And set id = "block1" for the required block.
To do this, the page needs blocks with an id to which scrolling will occur.
Example:
After adding, turn on the edit mode, hover over the menu "Edit menu items"
In the "link" field, enter #test1
If you need smooth scrolling, then this is already JavaScript.
$(document).ready(function(){
$('.go_to').click( function(){ // ловим клик по ссылке с классом go_to
var scroll_el = $(this).attr('href'); // возьмем содержимое атрибута href, должен быть селектором, т.е. например начинаться с # или .
if ($(scroll_el).length != 0) { // проверим существование элемента чтобы избежать ошибки
$('html, body').animate({ scrollTop: $(scroll_el).offset().top }, 500); // анимируем скроолинг к элементу scroll_el
}
return false; // выключаем стандартное действие
});
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question