css hover alternative (automatic)

css, hover, transition

Solution

You cannot handle click events on dom elements with css, you will need to use javascript for this.

You can add a click event to the first div which is fired when you click it. Within the event you select the other div, and make the transition.

Working Demo

You can do this by adding a class with the css transition:

Html:

<div id="clickme">1</div>
<div id="changeMe">2</div>

Javascript:

var el = document.getElementById('clickme');

el.onclick = function() {
    document.getElementById('changeMe').className = "transition";
};

CSS:

.transition{
   /* transition css */
}

Problem

My CSS has to change using a transition ,and till now i used `div:hover` for that. The transition needs to be activated when you click another `div`, not when you hover over the `div` that has to move/change . How can I do that ? Thanks Evert

Original source