淘宝悬浮侧边栏怎么做

淘宝悬浮侧边栏怎么做

sidebar {

position: fixed;

width: 200px;

height: 100%;

top: 0;

right: 0;

background-color: f9f9f9;

padding: 20px;

box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);

}

window.onscroll = function() {

var sidebar = document.getElementById(”sidebar”);

sidebar.style.top = window.pageYOffset + ”px”;

};

0

43