Is there a way to move an element within the screen using only an anchor and then center it?
- Is using scroll-padding the only way to bring an off-screen element to the center?
- Is there a method to bring an element that’s already on the screen to the center?
I am looking for a way to implement functionality similar to the following code using only HTML and CSS:
event.target.scrollIntoView({
behavior: 'smooth',
block: 'center',
inline: 'center'
});
JavaScript can solve the problem immediately, but I couldn’t solve it with just HTML and CSS.
New contributor
XIYO is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.