This exercise leverages clever CSS and jQuery to have a light switch toggle the "lights" on and off. The solution is provided as a guide -- don't peak!
https://tc-mccarthy.github.io/edu/exercises/js/jquery-intro-light-switch/solution/
Please create and clone a new repo called light-switch-demo
-
Set up a container and allow it to expand to be no wider than 800px. It should also center itself, have 5px of padding all around and the text it contains should be centered.
-
Add two H2s to the container that each have the
.lightclass. The first should also have an.onclass and the second an.offclass. The first should read Lights on and the second, lights off. -
Add a paragraph that reads
If the lights are turning on and off your javascript works!. -
Nest a second container within the first and give it a second
.imgclass. There should be overriding styles for the.img.containerelement that limits it to300pxwide,position: relativeand min-height of100vh. -
Inside of
.img.containeradd twoimgtags, the first with.light.onand pointing toimg/light-on.pngand the second with.light.offand pointing toimg/light-off.png. -
All
imgtags should have awidth: 100%;. If the have the class.lightthey should bedisplay: block,position: absolute;and be vertically centered. -
Anything with
.light.offshould not be displayed by default. When the body tag has.light-offanything with.light.onshould be hidden and anything with.light.offshould be displayed. -
When
bodyhas.light-offtext should be white and the background black. -
Finally, the following statements should be added to the top of your stylesheet to load the electrolize font.
@import url('https://fonts.googleapis.com/css?family=Electrolize');
and
font-family: 'Electrolize', sans-serif;
- The JS is very basic -- wait for the DOM to be ready and then begin listening for clicks on
.light.on. On click we should add the classlight-offtobody. It should be removed when.light.offis clicked on.