-1

I have 2 images, front and back of a robot.

I need html or CSS code (NO JAVA SCRIPT/JQUERY), so that when I click front, the front robot shows, and when I click back the back of the robot shows.

I found a tutorial the other day on google, and now I cant find it :S

Anyone got any ideas? I'm sure it must be simple. REMEMBER -NO JAVA SCRIPT PLEASE!

1 Answers1

2

CSS was not meant to be used like this but here is a work around.. something i call a BODGE. This will be using the :checked pseudo class - attach it to a pseudo element of a checkbox then change its background accordingly.

I have even put robot pictures in there for you ;)

CSS:

input[type="checkbox"] {
    content: url('http://www.thelemming.com/lemming/POP-CULTURE/asimo-robot_48.jpg');
    display: block;
    width: 200px;
    height: 200px;
    border: 1px solid black;
}
input[type="checkbox"]:checked {
    content: url('http://www.sstscorp.in/images/QRIO.jpg.jpg');
}
.native-hidden {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

HTML:

<input class="native-hidden" type="checkbox" />

you can change the images in the css to your robot ones, input[type="checkbox"] will be your first image on page load and input[type="checkbox"]:checked will be the picture when its clicked.

http://jsfiddle.net/joshstevens19/goyenhLd/2/

Josh Stevens
  • 3,943
  • 1
  • 15
  • 22