How to change an image on click using CSS alone?


Tags: html,css,image

Problem :

I have an image and when the image is clicked I want to reveal another image below it. I am looking for a simple CSS only solution.

Is that possible?



Solution :

You could use an <a> tag with different styles:

a:link    { }
a:visited { }
a:hover   { }
a:active  { } 

I'd recommend using that in conjunction with CSS sprites: http://css-tricks.com/158-css-sprites/


    CSS Howto..

    How to set the horizontal menu to be center without setting the specific width

    How would I detect CSS Transition support on :before pseudo-elements with javascript?

    How to set link color inside GridView cell

    How to resize button without cutting the text inside

    Show/Hide Html TR/TD

    How to set a (nice) linear-gradient from any color to transparent?

    Bootstrap glyphicon/nav bar showing popup window

    How can i get target with a hover an element under an element?

    Show nested list on click in Joomla (1.7.0)

    How does CSS handle specificity tie?

    How to create a dropdown that is open by default and with custom scrollbars ( see pic from wireframes) in HTML [closed]

    How to use jQuery to detect loaded background image after inserting out CSS

    How to contol a CSS property with Javascript

    How to align / valign css-rotated span within its parent div

    How to position HTML code over CSS

    How to fill the width under an image with a caption without defining the width of the caption?

    How can i center the list items inside my unordered list?

    How do I evenly space these links within my navbar div?

    How to manage length of dashes

    Odd visual effect (little line shows) when hovering over button in browser

    Compass delimited list separator - how to set to – [duplicate]

    Is it possible to have a web browser scroll to show CSS fixed position items that are outside the viewport of the web browser?

    How to get CSS file to affect only a section of HTML

    How do I hide the borders around checkboxes in an ASP.Net CheckBoxList control with jQuery?

    How to handle the html and css of one side image and other side content and vice versa

    how to get value of colors from CSS

    How to turn off :hover with CSS?

    How to test a web designer on css layouts?

    How to make this character to be placed at the right side of its container?

    How to work with dynamic container in Isotope?