Increase a div size on click with css alone
问题 I want to increase the width of my div when I click on it. I want to achieve this with CSS alone. Is it possible? I made it increase in width via hover, but I need the same effect to happen when I click on the div. Suggestions are appreciated. HTML <div id="sample"></div> CSS #sample{ width:100px; height:100px; background:#000000; } I want to change the width to 200px on click. 回答1: One potential solution would be to add a tabindex attribute to the div , like so: <div id="sample" tabindex="0"