<html>
<head>
<style>
html,body{
scroll-behavior: smooth
}
.item{
height:100vh;
}
nav{
position: fixed;
width:100%;
}
#portfolio{
background: #cc0;
}
#scills{
background: #0c0;
}
#about{
background: #c00;
}</style>
</head>
<body>
<nav>
<a href="#portfolio">Портфолио</a>
<a href="#scills">Опыт</a>
<a href="#about">Обо мне</a>
</nav>
<div id="portfolio" class="item"></div>
<div id="scills" class="item"></div>
<div id="about" class="item"></div>
<script>
const aClick = (e) => {
e.preventDefault();
const target = e.target.href.split('#')[1];
console.log(target);
const offsetTop = document.getElementById(target).offsetTop;
window.scrollTo(0, offsetTop);
window.history.pushState({}, document.title, '/'+target);
};
[...document.getElementsByTagName('a')].forEach(i=>{
i.addEventListener('click', aClick);
});
</script>
</body>
</html>