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
.light
class. The first should also have an.on
class and the second an.off
class. 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
.img
class. There should be overriding styles for the.img.container
element that limits it to300px
wide,position: relative
and min-height of100vh
. -
Inside of
.img.container
add twoimg
tags, the first with.light.on
and pointing toimg/light-on.png
and the second with.light.off
and pointing toimg/light-off.png
. -
All
img
tags should have awidth: 100%;
. If the have the class.light
they should bedisplay: block
,position: absolute;
and be vertically centered. -
Anything with
.light.off
should not be displayed by default. When the body tag has.light-off
anything with.light.on
should be hidden and anything with.light.off
should be displayed. -
When
body
has.light-off
text 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-off
tobody
. It should be removed when.light.off
is clicked on.