Sam Tobin-Hochstadt
Sam Tobin-Hochstadt

Reputation: 5053

css for permanent change on mouseover

It's easy to swap two elements on hover, with use of the visibility: hidden and :hover. However, I want the second state, with the replaced element, to persist even when the mouse leaves the element. This would be easy to do with JavaScript, but is there a way to do it in pure CSS?

Upvotes: 0

Views: 1150

Answers (1)

Billy Moon
Billy Moon

Reputation: 58619

CSS is stateless, so no there is no way to change the state in a permanent way. The only way I can think of to come close, is to increase the size of the element (or have a sub-element that is big) so that the mouse does not leave, but it would obscure the rest of the page and controls.

Upvotes: 2

Related Questions