На данный вопрос уже ответили:
Здравствуйте опишу проблему.
Есть блок А (с каким то текстом). ниже идет блок Б (меню сайта). еще ниже идет блок В (слайдеры).
Как сделать так чтобы, при прокрутке когда блок А заканчивается, меню прикрепляется к верху и больше не слетает, пока не открутишь назад. Пример так как я хочу есть на сайте: http://boleu.net
Получаете состояние прокрутки с помощью var scrolled = window.pageYOffset || document.documentElement.scrollTop;
и в зависимости от того виден ли блок А указываете для блока B position: fixed;
или position: inherit;
window.onscroll = function() {
var scrolled = window.pageYOffset || document.documentElement.scrollTop;
document.getElementById('B').style.position = scrolled > 150 ? 'fixed' : 'inherit';
}
* {
margin: 0;
padding: 0;
}
.A {
width: 100%;
height: 150px;
background: #EEE;
}
.B {
top: 0;
left: 0;
width: 100%;
height: 50px;
background: #66A;
}
<div class='A'></div>
<div id='B' class='B'></div>
<p>Make ten changes at the same time, not one change ten times. Multiple selections allow you to interactively change many lines at once, rename variables with ease, and manipulate files faster than ever.Make ten changes at the same time, not one change ten times. Multiple selections allow you to interactively change many lines at once, rename variables with ease, and manipulate files faster than ever.</p>
<p>Make ten changes at the same time, not one change ten times. Multiple selections allow you to interactively change many lines at once, rename variables with ease, and manipulate files faster than ever.Make ten changes at the same time, not one change ten times. Multiple selections allow you to interactively change many lines at once, rename variables with ease, and manipulate files faster than ever.</p>
<p>Make ten changes at the same time, not one change ten times. Multiple selections allow you to interactively change many lines at once, rename variables with ease, and manipulate files faster than ever.Make ten changes at the same time, not one change ten times. Multiple selections allow you to interactively change many lines at once, rename variables with ease, and manipulate files faster than ever.</p>
<p>Make ten changes at the same time, not one change ten times. Multiple selections allow you to interactively change many lines at once, rename variables with ease, and manipulate files faster than ever.Make ten changes at the same time, not one change ten times. Multiple selections allow you to interactively change many lines at once, rename variables with ease, and manipulate files faster than ever.</p>
<p>Make ten changes at the same time, not one change ten times. Multiple selections allow you to interactively change many lines at once, rename variables with ease, and manipulate files faster than ever.Make ten changes at the same time, not one change ten times. Multiple selections allow you to interactively change many lines at once, rename variables with ease, and manipulate files faster than ever.</p>
<p>Make ten changes at the same time, not one change ten times. Multiple selections allow you to interactively change many lines at once, rename variables with ease, and manipulate files faster than ever.Make ten changes at the same time, not one change ten times. Multiple selections allow you to interactively change many lines at once, rename variables with ease, and manipulate files faster than ever.</p>
<p>Make ten changes at the same time, not one change ten times. Multiple selections allow you to interactively change many lines at once, rename variables with ease, and manipulate files faster than ever.Make ten changes at the same time, not one change ten times. Multiple selections allow you to interactively change many lines at once, rename variables with ease, and manipulate files faster than ever.</p>
<p>Make ten changes at the same time, not one change ten times. Multiple selections allow you to interactively change many lines at once, rename variables with ease, and manipulate files faster than ever.Make ten changes at the same time, not one change ten times. Multiple selections allow you to interactively change many lines at once, rename variables with ease, and manipulate files faster than ever.</p>
Кофе для программистов: как напиток влияет на продуктивность кодеров?
Рекламные вывески: как привлечь внимание и увеличить продажи
Стратегії та тренди в SMM - Технології, що формують майбутнє сьогодні
Выделенный сервер, что это, для чего нужен и какие характеристики важны?
Современные решения для бизнеса: как облачные и виртуальные технологии меняют рынок
Как можно сделать ввод текста с возможностью форматирования (жирный/курсив/цветной итд
Собственно есть рамка в фотошопе, но как сверстать - не знаюПолучается криво
Доверстываю шаблон, нужно чтобы меню при любом, даже самом малом разрешении, оставалось неизменной