For older browsers, you might need to manually animate the scroll. Here’s a quick snippet:
```js
function smoothScroll(element) {
element.scrollIntoView({ behavior: 'smooth', block: 'start' });
if (!('scrollBehavior' in document.documentElement.style)) {
// Fallback for older browsers
const targetPos = element.getBoundingClientRect().top;
window.scrollBy({ top: targetPos, behavior: 'smooth' });
}
}
```
Not perfect, but better than nothing!
```js
function smoothScroll(element) {
element.scrollIntoView({ behavior: 'smooth', block: 'start' });
if (!('scrollBehavior' in document.documentElement.style)) {
// Fallback for older browsers
const targetPos = element.getBoundingClientRect().top;
window.scrollBy({ top: targetPos, behavior: 'smooth' });
}
}
```
Not perfect, but better than nothing!
